2

I have this problem where I added a macro to set the visibility of certain functions to my code like this:

#define PUBLIC_API __attribute__((visibility("default")))

The problem is that it seems to have broken the formatting when displaying the functions in Sphinx..

Changing the function docs from this:

struct conductor* conductor_create(struct conductor_error* err);

enter image description here

to this:

PUBLIC_API struct conductor* conductor_create(struct conductor_error* err);

enter image description here

Is there any way I can get that nice auto-formatting back? I would like to not see the macro there at all if possible..

Here's what I was using in the Sphinx .rst for that part if that's relevant:

C API
=====
```/lib/c++/X2XConductorC.h```

.. doxygenfile:: X2XConductorC.h
   :project: X2XConductor

I set up the documentation more or less as described here: https://devblogs.microsoft.com/cppblog/clear-functional-c-documentation-with-sphinx-breathe-doxygen-cmake/

bad_coder
  • 11,289
  • 20
  • 44
  • 72
catflaps
  • 135
  • 1
  • 3
  • 1
    I've just figured out you can get doxygen to ignore blocks of code with the tags: ``` ///@cond INTERNAL PUBLIC_API ///@endcond ``` I've done this in the function declarations and it's good enough for my purposes, but if there's a proper way of going about it please do share – catflaps Oct 07 '20 at 02:28
  • 1
    Please also have a look at `\internal` and at the doxygen PREDEFINED configuration setting (for PUBLIC_API) – albert Oct 07 '20 at 07:38
  • I managed to resolve this problem by enabling `MACRO_EXPANSION` in the Doxyfile configuration. This might not work if you still want to have the macro in the documentation (or if it always has a definition), but it seemed to work for my visibility macros – Dekker1 Jul 04 '22 at 07:08
  • I ended up moving documenting the functions in the source `.c` file instead of the header file. Former doesn't contain the visibility macros so everything works fine. – thilinarmtb Aug 18 '23 at 05:19

0 Answers0