breathe icon indicating copy to clipboard operation
breathe copied to clipboard

Unable to resolve function warnings when C files have extension .C (capital C)

Open bennyrowland opened this issue 3 years ago • 3 comments

I am not sure if this is a Doxygen issue or a Breathe one, but hoping someone here might have a better idea of what is going on or how to fix it. At the very least, anybody that meets the same problem in the future might find this issue helpful. I inherited some legacy C code and went to properly document it using Sphinx and Breathe, but starting getting all these warnings using the doxygenfunction directive (examples taken from a toy project I created to test this out):

 WARNING: doxygenfunction: Unable to resolve function "hello" with arguments None in doxygen xml output for project
 "oblqtran" from directory: H:/untitled/docs/_build/xml.
Potential matches:
- void hello(void)
- void hello(void)

This seemed to be finding one copy of the function from the header file and one from the source file, as if I removed the public header directory this error went away (but then I couldn't get any of the typedefs etc. that were only in that file). After a few days of scratching my head (well mainly cursing and throwing things at the computer) I finally discovered that the problem was caused by the code file having the extension .C with a capital letter C rather than .c. Compiling library.C causes Doxygen to produce a library_8_c.xml file, compiling the same code in library.c produces a library_8c.xml (this seems to be in general keeping with the way that Doxygen handles capital letters in filenames, replacing X with _x. I don't however understand why the library_8c.xml file works for Breathe and library_8_c.xml doesn't, the files seem to be otherwise identical, as do their respective index.xml files. Might be worth pointing out that I am on Windows and therefore not natively case-sensitive so there might be something weird going on there.

As I say, this problem seems to have an easy work-around, I will simply rename all my files and move on to enjoying using Breathe. At the very least, this issue will hopefully be available to help anybody else who runs into the same thing in the future. If anybody does have an insight into solving it though then that would be great, I have a lot more old code with capitalised extensions that I would rather not have to rename.

bennyrowland avatar May 28 '21 10:05 bennyrowland

You could try adding breathe_domain_by_extension = {"C" : "cpp"} (or c instead, if you want to use the C domain).

See: https://breathe.readthedocs.io/en/latest/directives.html#confval-breathe_domain_by_extension

utzig avatar May 28 '21 11:05 utzig

@utzig Thanks for the suggestion, however it doesn't seem to make a difference to my results, either trying {"C": "cpp"} or {"C": "c"}.

bennyrowland avatar May 28 '21 12:05 bennyrowland

@bennyrowland I tried reproduction on Breathe a06ad448e43f450823904766e184ae217e4ff070 with following diff:

diff --git a/documentation/source/code/nutshell.h b/documentation/source/code/nutshell.H
similarity index 97%
rename from documentation/source/code/nutshell.h
rename to documentation/source/code/nutshell.H
index b1e559d..7ecb0db 100644
--- a/documentation/source/code/nutshell.h
+++ b/documentation/source/code/nutshell.H
@@ -1,5 +1,5 @@
 /**
-    \file nutshell.h
+    \file nutshell.H
     An overly extended example of how to use breathe
 */
 
diff --git a/documentation/source/file.rst b/documentation/source/file.rst
index 11c103f..7231baa 100644
--- a/documentation/source/file.rst
+++ b/documentation/source/file.rst
@@ -71,14 +71,14 @@ Example
 
 This should work::
 
-   .. doxygenfile:: nutshell.h
+   .. doxygenfile:: nutshell.H
       :project: nutshell
 
 It produces this output:
 
 ----
 
-.. doxygenfile:: nutshell.h
+.. doxygenfile:: nutshell.H
    :project: nutshell
 
 Example with Selected and Ordered Sections
@@ -89,7 +89,7 @@ Example with Selected and Ordered Sections
 The following will only show the **briefdescription** and **public-type**
 sections, in that order::
 
-   .. doxygenfile:: nutshell.h
+   .. doxygenfile:: nutshell.H
       :project: nutshell
       :sections: briefdescription innerclass public-type
 
@@ -97,7 +97,7 @@ It produces this output:
 
 ----
 
-.. doxygenfile:: nutshell.h
+.. doxygenfile:: nutshell.H
    :project: nutshell
    :sections: briefdescription innerclass public-type
 
diff --git a/documentation/source/index.rst b/documentation/source/index.rst
index a066cde..ff520fc 100644
--- a/documentation/source/index.rst
+++ b/documentation/source/index.rst
@@ -109,7 +109,7 @@ In a Nutshell
 
 You write code that looks a little like this:
 
-.. literalinclude:: code/nutshell.h
+.. literalinclude:: code/nutshell.H
    :language: cpp
 
 Then you run this::
diff --git a/examples/specific/Makefile b/examples/specific/Makefile
index af09fa0..618f33b 100644
--- a/examples/specific/Makefile
+++ b/examples/specific/Makefile
@@ -3,9 +3,9 @@
 #
 
 DOXYGEN   ?= `which doxygen`
-TMAKEPATH = 
+TMAKEPATH =
 ENV       = env TMAKEPATH=$(TMAKEPATH)
-TMAKE     = 
+TMAKE     =
 MAKE      = /usr/bin/make
 PERL      = /usr/bin/perl
 RM        = rm -f
@@ -15,10 +15,10 @@ INSTALL   = /tmp
 INSTTOOL  = /usr/bin/install
 DOXYDOCS  = ..
 DOCDIR    = $(INSTALL)/share/doc/packages/doxygen
-QTDIR     = 
+QTDIR     =
 HAVE_DOT  = /usr/bin/dot
 
-projects  = nutshell alias rst inline namespacefile array inheritance \
+projects  = alias rst inline namespacefile array inheritance \
 			members userdefined fixedwidthfont latexmath functionOverload \
 			image name union group struct struct_function qtsignalsandslots lists \
 			headings links parameters template_class template_class_non_type \
@@ -29,7 +29,7 @@ projects  = nutshell alias rst inline namespacefile array inheritance \
 			cpp_function_lookup \
 			c_file c_struct c_enum c_typedef c_macro c_union membergroups
 
-special   = programlisting decl_impl multifilexml auto class typedef
+special   = programlisting decl_impl multifilexml auto class typedef nutshell
 
 xmls := $(foreach project, $(projects), $(project)/xml/index.xml)
 
@@ -44,7 +44,7 @@ clean:
 # General pattern
 # ---------------
 
-$(xmls): %/xml/index.xml: %.cfg %.h 
+$(xmls): %/xml/index.xml: %.cfg %.h
 	$(DOXYGEN) $<
 
 
@@ -68,3 +68,6 @@ class/xml/index.xml: class.h class.cpp class.cfg
 
 typedef/xml/index.xml: typedef.h typedef.cfg
 	$(DOXYGEN) typedef.cfg
+
+nutshell/xml/index.xml: nutshell.H nutshell.cfg
+	$(DOXYGEN) nutshell.cfg
diff --git a/examples/specific/nutshell.h b/examples/specific/nutshell.H
similarity index 97%
rename from examples/specific/nutshell.h
rename to examples/specific/nutshell.H
index 64e1b1b..dbe7989 100644
--- a/examples/specific/nutshell.h
+++ b/examples/specific/nutshell.H
@@ -1,5 +1,5 @@
 /**
-    \file nutshell.h
+    \file nutshell.H
     An overly extended example of how to use breathe
 */
 
diff --git a/examples/specific/nutshell.cfg b/examples/specific/nutshell.cfg
index 312feb3..88333dc 100644
--- a/examples/specific/nutshell.cfg
+++ b/examples/specific/nutshell.cfg
@@ -4,7 +4,7 @@ GENERATE_LATEX   = NO
 GENERATE_MAN     = NO
 GENERATE_RTF     = NO
 CASE_SENSE_NAMES = NO
-INPUT            = nutshell.h
+INPUT            = nutshell.H
 QUIET            = YES
 JAVADOC_AUTOBRIEF = YES
 GENERATE_HTML = NO

Then I run make html in root of Breathe repo (you may need to set PYTHONPATH or similar, not sure how it works on Windows).

However, behaviour here is correct and I do not see any issues. Could you test with Breathe repo or otherwise provide minimal example? At this point it appears to be an issue with your specific environment.

Thanks

vermeeren avatar Sep 18 '21 03:09 vermeeren