clang completion undefining builtin defines

General questions regarding the usage of CodeLite
Tomeamis
CodeLite Curious
Posts: 2
Joined: Sun Jan 08, 2017 5:55 pm
Genuine User: Yes
IDE Question: C++
Contact:

clang completion undefining builtin defines

Post by Tomeamis »

Hello,
when using Clang code completion, there is a way to specify command line defines (-D<macro>) in the project settings.
Is there a way to undefine sumething (-U<macro>)? I need this to work around platform detection macros.
A way to specify -nostdinc would also be nice, but is not completely necessary for me.
Thanks.
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: clang completion undefining builtin defines

Post by eranif »

When using clang code completion, CodeLite passes to libclang the exact build line from the project settings.
i.e. you just need to create a build configuration with the proper settings - you don't need to do something special for making clang work
Make sure you have read the HOW TO POST thread
Tomeamis
CodeLite Curious
Posts: 2
Joined: Sun Jan 08, 2017 5:55 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: clang completion undefining builtin defines

Post by Tomeamis »

Unfortunately, it doesn't seem to work.
If you unpack the attached archive, on line 17 clang suggests bar after the dot, but thanks to the -U__GNUC__ in the project settings,
it should suggest baz. If you accept the completion and build the project, you get a compilation error, because bar is not a member of the struct.
Also, how would it be possible to specify undefs in projects with custom Makefiles?
You do not have the required permissions to view the files attached to this post.
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: clang completion undefining builtin defines

Post by eranif »

Thanks for providing a sample workspace.
Indeed, the -U was not passed to libclang so it was always defined which caused the wrong entry to show in the code completion.

This is now fixed in git master and will be available in the next weekly build (or you can build your own CodeLite from git)
Make sure you have read the HOW TO POST thread
Post Reply