Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » BOP Define descovery gives empty values(I need to find the options to make -DXYZ cause #ifdef XYZ to be set true)
BOP Define descovery gives empty values [message #1744404] Mon, 26 September 2016 15:20 Go to next message
Richard Schelin is currently offline Richard SchelinFriend
Messages: 2
Registered: September 2016
Junior Member
The problem is simple, we (large team, I'm just a small cog, so changing the flow is not in my purview)

I have gotten the BOP to consume the build information and most things work great. What I have noticed is we have a line that has something like:
g++ .... -DDEBUG -DXYZ -DABC

Then we have a section of code that uses those:

#ifdef DEBUG
<DEBUG logic>
#endif

g++ interprets the above so the <DEBUG logic> is included, CDT does not.

Looking into properties->C/C++ General->Preprocessor Include Paths, Macros etc. -> Setting Entries -> CDT GCC Build Output Parser I see:

# DEBUG=

So it is finding the line, but it has no value.

I can work around this by setting the variable by hand, but this then breaks when I change build parameters and get different build results, it also makes it so I have to hand edit settings each time I bring up eclipse in a client area.

Did I miss an option, I searched the forums (and google) but could not find a solution.

I'm using Eclipse Mars with the latest Mars CDT release. We use Perforce as a repository and I found that pllugin has not been enabled for Neon when I started playing with all this.

Thanks for any help!

Rich


Re: BOP Define descovery gives empty values [message #1744437 is a reply to message #1744404] Tue, 27 September 2016 01:04 Go to previous messageGo to next message
David VavraFriend
Messages: 1413
Registered: October 2012
Senior Member
It doesn't have a value because the definition being used doesn't have a value.
-DDEBUG means define it with no defined value (actually it's probably zero).


You'll have to use -DDEBUG=v if you want Eclipse to see the value.

I've never tried it but you can give a macro file to Eclipse. Maybe you just need to have a file with your configuration macro definitions set as needed.

Maybe you should submit a bug report.

EDIT:

I've been doing some playing around. I have some test code where the macro is defined in the preprocessor entries dialog but Eclipse acts as though it isn't there. If I define it in a CDT parser block in the code it does see it. However not all macros need this.

It is defined as DEBUGX=1 in both Preprocessor... and Paths and Symbols.
It's not consistent.

index.php/fa/27223/0/
index.php/fa/27222/0/




[Updated on: Tue, 27 September 2016 10:42]

Report message to a moderator

Re: BOP Define descovery gives empty values [message #1744513 is a reply to message #1744437] Tue, 27 September 2016 15:27 Go to previous message
Richard Schelin is currently offline Richard SchelinFriend
Messages: 2
Registered: September 2016
Junior Member
Thanks David for the ideas.

So I went to go create a small testcase to show the issue, and I'm failing to reproduce it in my small example.

I have no control over the build flow, I work on a project with hundreds of contributors and I'm not a big enough cog to make sweeping changes, so I need to get the tools to work for me Smile

I created a new makefile project, and added this to the main():

int main() {
#ifdef DEBUG
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
#endif

Then I added to the testing.cpp file's properties (that contains the above) in the C/C++ build-.Settings->Tool Settings->Debugging->Other debugging flags "-DDEBUG"

Then I enabled the BOP and did a clean build, and Eclipse changes the ifdef above from grey to white, indicating it is defined.

I have the exact same scenario in my much larger build (BOP detects -DDEBUG, sets it the exact same way) but it is not recognized as "defined".

I have to wonder what the difference is between the runs.

Rich

Invoking: GCC C++ Compiler
g++ -O0 -g3 -DDEBUG -Wall -c -fmessage-length=0 -MMD -MP -MF"src/testing.d" -MT"src/testing.d" -o "src/testing.o" "../src/testing.cpp"



Previous Topic:Debug strings without <repeats x times> ?
Next Topic:Debugging arduino (samd) target
Goto Forum:
  


Current Time: Sun Jan 23 02:25:53 GMT 2022

Powered by FUDForum. Page generated in 0.02141 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top