Qt Creator - Clang Code Model with GNU code
-
How can I tell the Code Model to use '-std=gnu11' ?
So that it wouldn't flag things like nested functions as "error: function definition is not allowed here".When I try to add it as "Diagnostic Configuration" I get told: 'Option "-std=gnu11" is invalid.'
Is this a limitation from libclang, or is the Option-validation-checker too strict?Thanks
-
How can I tell the Code Model to use '-std=gnu11' ?
So that it wouldn't flag things like nested functions as "error: function definition is not allowed here".When I try to add it as "Diagnostic Configuration" I get told: 'Option "-std=gnu11" is invalid.'
Is this a limitation from libclang, or is the Option-validation-checker too strict?Thanks
@dawnwhite said in Qt Creator - Clang Code Model with GNU code:
So that it wouldn't flag things like nested functions as "error: function definition is not allowed here".
Well, this is not standard C++, so don't do it to begin with. Use an anonymous struct/class instead:
void function() { struct { void operator () (int a) { } } nested; int b = 0; nested(b); }
Or simply use a lambda.
When I try to add it as "Diagnostic Configuration" I get told: 'Option "-std=gnu11" is invalid.'
Is this a limitation from libclang, or is the Option-validation-checker too strict?I don't believe
libclang
supports gnu extensions. -
Thank your for your response!
so don't do it to begin with.
I work with an large existing code base, so this is not an option. Think of the linux kernel for example.
I was able to set
-std=gnu11
by editing~/.config/QtProject/QtCreator.ini
manually, and now many gcc extensions are supported.
It would be great if this was supported by the gui somehow. A quick hack would be to whitelist-std=*
in isValidOption.I don't believe libclang supports gnu extensions.
While nested functions indeed seem to be unsupported, many GNU extensions are supported! From LanguageExtensions.html:
Clang aims to support a broad range of GCC extensions
. -
Thank your for your response!
so don't do it to begin with.
I work with an large existing code base, so this is not an option. Think of the linux kernel for example.
I was able to set
-std=gnu11
by editing~/.config/QtProject/QtCreator.ini
manually, and now many gcc extensions are supported.
It would be great if this was supported by the gui somehow. A quick hack would be to whitelist-std=*
in isValidOption.I don't believe libclang supports gnu extensions.
While nested functions indeed seem to be unsupported, many GNU extensions are supported! From LanguageExtensions.html:
Clang aims to support a broad range of GCC extensions
.@dawnwhite said in Qt Creator - Clang Code Model with GNU code:
I work with an large existing code base, so this is not an option. Think of the linux kernel for example.
Think refactoring. I sure hope the kernel doesn't require extensions to the C language just to compile.
I was able to set
-std=gnu11
by editing~/.config/QtProject/QtCreator.ini
manually, and now many gcc extensions are supported.Thanks for sharing!
While nested functions indeed seem to be unsupported, many GNU extensions are supported! From LanguageExtensions.html:
Clang aims to support a broad range of GCC extensions
.Well, yeah, I mean in the general sense of "all" gnu extensions. People try to play nice, and personally I like to use the gcc attributes with clang as well.