Community
Participate
Working Groups
Created attachment 246290 [details] Eclipse project and settings that reproduce erroneous CA fail When working with the snapper code in CDT, I saw that Snapper.cc was failing CA. Attached is a Repro of the problem. Basically, CA can't handle dual #define's, like so: #define THIS THAT "there" It requires the following: #define THIS "there" #define THAT "there"
(In reply to G. Richard Bellamy from comment #0) > Basically, CA can't handle dual #define's, like so: > > #define THIS THAT "there" > > It requires the following: > > #define THIS "there" > #define THAT "there" If you're expecting '#define THIS THAT "there"' to define two object-style macros, 'THIS' and 'THAT', both with value "there", then this is not standard C++. What compiler compiles your example project? Trying with gcc 4.9, I get: cdt-ca-bug-repro.cpp: In function 'int main()': cdt-ca-bug-repro.cpp:12:19: error: 'ANOTHERTHING' was not declared in this scope #define SOMETHING ANOTHERTHING "this" ^ cdt-ca-bug-repro.cpp:19:39: note: in expansion of macro 'SOMETHING' DualDefineError dualTypedefSomething(SOMETHING); ^
Well, that's embarrassing, I didn't even try to compile my repro. The thing that got me looking at this is that in snapper, there is a construct exactly like this, and there are no compile errors when building. Here's the consruct: https://github.com/openSUSE/snapper/blob/9f96170ae0552efbe2be8ac6dd52c0c3ff7a9bc4/snapper/SnapperDefines.h#L29 Here's where its used: https://github.com/openSUSE/snapper/blob/9f96170ae0552efbe2be8ac6dd52c0c3ff7a9bc4/snapper/Snapper.cc#L285 CA definitely shows an error for that Line 285 in Snapper.cc. However, the compiler works, easy-peasy: /bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -I/usr/include/libxml2 -DCONFDIR='"/etc/conf.d"' -D_FILE_OFFSET_BITS=64 -g -O2 -std=c++0x -Wall -Wextra -Wformat=2 -Wnon-virtual-dtor -Wno-unused-parameter -MT Snapper.lo -MD -MP -MF .deps/Snapper.Tpo -c -o Snapper.lo Snapper.cc libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -I/usr/include/libxml2 -DCONFDIR=\"/etc/conf.d\" -D_FILE_OFFSET_BITS=64 -g -O2 -std=c++0x -Wall -Wextra -Wformat=2 -Wnon-virtual-dtor -Wno-unused-parameter -MT Snapper.lo -MD -MP -MF .deps/Snapper.Tpo -c Snapper.cc -fPIC -DPIC -o .libs/Snapper.o Snapper.cc: In destructor 'snapper::Snapper::~Snapper()': Snapper.cc:116:20: warning: 'void snapper::Snapshot::flushInfo()' is deprecated (declared at ../snapper/Snapshot.h:111) [-Wdeprecated-declarations] it->flushInfo(); So I assumed there was a problem with CA and since I haven't done any C++ in over 5 years, I assumed I knew /where/ the problem was.
(In reply to G. Richard Bellamy from comment #2) > Here's the consruct: > https://github.com/openSUSE/snapper/blob/ > 9f96170ae0552efbe2be8ac6dd52c0c3ff7a9bc4/snapper/SnapperDefines.h#L29 For this line to be valid, CONFDIR must be defined as another macro somewhere. I notice you have -DCONFDIR='"/etc/conf.d"' in your compiler command line, which defines CONFDIR as a macro without it having to be defined in a source file. My guess is, something goes wrong in your project configuration and Eclipse doesn't pick up this macro. Possibly the build output parser doesn't recognize your build command because you're calling g++ indirectly via libtool (making this a bug / missing feature in the build output parser). Defining the CONFDIR macro manually in Project Properties -> C/C++ General -> Preprocessor Include Paths, Macros etc. -> Entries -> GNU C++ -> CDT User Setting Entries should work around an issue like this.