Hello,
I am struggling with CODAN errors on a project which uses C++ anonymous unions.
As far as I can see, I can reproduce this problem by adding these two files to an empty C++ project using the ‘MinGW GCC’ toolchain in CDT 8.0.0.201109151620
unionheader.h
-------------------------
static union {
int a2;
int b2;
};
namespace test {
static union {
int a3;
int b3;
};
}
-------------------------
main.cpp
--------------------------
static union {
int a;
int b;
};
#include "unionheader.h"
int main(void) {
a = 1; // works
b = 2; // works
a2 = 1; // CODAN 'Symbol 'a2' could not be resolved'
b2 = 2; // CODAN 'Symbol 'b2' could not be resolved'
test::a3 = 1; // CODAN 'Symbol 'a3' could not be resolved'
test::b3= 2; // CODAN 'Symbol 'b3' could not be resolved'
return 0;
}
-------------------------
Apparently, the indexer will only be able to resolve the a, b symbols when editing main.cpp. Auto-completion on the “test” namespace works, but none of its symbols are being resolved. CODAN will report errors on all the symbols declared in the header file:
Description Resource Path Location Type
Symbol 'a2' could not be resolved main.cpp /anonymousUnionCPP_GNU/src line 12 Semantic Error
Symbol 'a3' could not be resolved main.cpp /anonymousUnionCPP_GNU/src line 15 Semantic Error
Symbol 'b2' could not be resolved main.cpp /anonymousUnionCPP_GNU/src line 13 Semantic Error
Symbol 'b3' could not be resolved main.cpp /anonymousUnionCPP_GNU/src line 16 Semantic Error
The code compiles without errors.
**** Rebuild of configuration Debug for project anonymousUnionCPP_GNU ****
**** Internal Builder is used for build ****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o src\main.o ..\src\main.cpp
g++ -o anonymousUnionCPP_GNU.exe src\main.o
Build complete for project anonymousUnionCPP_GNU
Time consumed: 290 ms.
Is there any specific indexer setting which I need to enable to resolve the union declarations in the included file?
Thanks for your help!
/ Mario Pierro