Doxygen using Clang on C sources

96 Views Asked by At

Using Doxygen with CLANG_ASSISTED_PARSING = YES on a batch of plain C files yields many warnings that are C++ related, notably on assignment/initialization and type conversion.

On Doxygen, I also have OPTIMIZE_OUTPUT_FOR_C = YES.

I can experience it with any trivial conceptual error, like these:

struct sTest {
    char * text;
    int value;
};

const struct sTest foo[] = {
    {"one", 1},
    {"two", 2},
    {"three", 3}
};

which don't generate any warning compiling for C, but in Doxygen log they results as:

Preprocessing C:/[path]/main.c...
error: C:/[path]/main.c:282:6: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings] [clang]
error: C:/[path]/main.c:283:6: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings] [clang]
error: C:/[path]/main.c:284:6: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings] [clang]

Note: Yes, I know that the compiler/static analyzer messages are grounded in this case; however, I chose the example to clearly show that a C++ analysis seems to be running, not a C one as I would expect.

That the same batch of files compiled with clang -Wall -Wextra *.c -o out.exe shows no warnings

[EDIT]

This is how I hoped to solve it:

P.S.: What's important, for anyone facing it too, is that I solved it with CLANG_OPTIONS = -std=c11 -- that's more or less what I expected Doxygen to do, when optimizing for C

Doesn't work on Windows though: when I add the option Clang fails to read all the input .c files:

Preprocessing C:/[path]/main.c...
error: clang: Failed to parse translation unit C:/[path]/main.c

But still opens all .h ones!

I mean that having in that path main.c and main.h only the second one is opened without any error. Yet have no idea why...

0

There are 0 best solutions below