This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
struct a_struct { enum { foo, bar, baz } field; }; int main(int argc, char *argv[]) { struct a_struct test; test.field = foo; } /* This code is completely valid c99 and will run and execute without problem with -std=c99. However the Netbeans parser breaks and reports "Unable to resolve identifier foo" making Netbeans programming in source code containing this pattern impossible. */
The code is not compilable ... g++ -c -g -MMD -MP -MF build/Debug/Cygwin_4.x-Windows/main.o.d -o build/Debug/Cygwin_4.x-Windows/main.o main.cpp main.cpp: In function ‘int main(int, char**)’: main.cpp:20: error: ‘foo’ was not declared in this scope make[2]: *** [build/Debug/Cygwin_4.x-Windows/main.o] Error 1 make[2]: Leaving directory `/cygdrive/c/Users/ap153252/Documents/NetBeansProjects/CppApplication_3' make[1]: Leaving directory `/cygdrive/c/Users/ap153252/Documents/NetBeansProjects/CppApplication_3' make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 BUILD FAILED (exit value 2, total time: 19s) The parser works fine if you improve your code e.g. ... test.field = a_struct::foo; ...
Alexander, have you checked C compiler with c99 standard? Looks like you tried C++ with default standard. It is not P1 blocker issue. Changing priority as well.
(In reply to comment #1) > The code is not compilable > ... > g++ -c -g -MMD -MP -MF build/Debug/Cygwin_4.x-Windows/main.o.d -o > build/Debug/Cygwin_4.x-Windows/main.o main.cpp > main.cpp: In function ‘int main(int, char**)’: > main.cpp:20: error: ‘foo’ was not declared in this scope > make[2]: *** [build/Debug/Cygwin_4.x-Windows/main.o] Error 1 > make[2]: Leaving directory > `/cygdrive/c/Users/ap153252/Documents/NetBeansProjects/CppApplication_3' > make[1]: Leaving directory > `/cygdrive/c/Users/ap153252/Documents/NetBeansProjects/CppApplication_3' > make[1]: *** [.build-conf] Error 2 > make: *** [.build-impl] Error 2 > > > BUILD FAILED (exit value 2, total time: 19s) > > The parser works fine if you improve your code e.g. > ... > test.field = a_struct::foo; > ... Why are you using C++? This is C99...
I can confirm this bug. I just stumbled upon the same problem where I declared a struct containing an enum in a header file. In the complementing .c file the enum values produce the mentioned error: "unable to resolve identifier (...)" For some reason, if I copy-paste the struct declaration to the .c file, the errors disappear. Of course, this is not a solution. It will only spark a ton of "redeclation of enumerator (...) errors. I can't find a solid workaround. It is indeed valid code in c99, so a bug in netbeans.
fixed, change set: http://hg.netbeans.org/cnd-main/rev/f2ca4012c1f1
Integrated into 'main-silver', will be available in build *201402130001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/f2ca4012c1f1 User: Alexander Simon <alexvsimon@netbeans.org> Log: ficed Bug #216764 C99: Parser fails to parse enum members declared in a struct