| Summary: | Inconsistent empty preprocessor define handling by build / core / parser | ||
|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | James Blackburn <jamesblackburn+eclipse> |
| Component: | cdt-core | Assignee: | Project Inbox <cdt-core-inbox> |
| Status: | NEW --- | QA Contact: | Jonah Graham <jonah> |
| Severity: | normal | ||
| Priority: | P3 | CC: | Alex.Burr, cdt-build-inbox |
| Version: | 7.0 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux-GTK | ||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 275779 | ||
Interestingly if I change the -D to just
-DDEFINED
the parser no longer complains but the compiler does:
Building file: ../src/parser_issue.c
Invoking: GCC C Compiler
gcc -DDEFINED -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/parser_issue.d" -MT"src/parser_issue.d" -o"src/parser_issue.o" "../src/parser_issue.c"
../src/parser_issue.c: In function 'main':
../src/parser_issue.c:14: error: expected declaration specifiers before numeric constant
../src/parser_issue.c:17: error: expected '{' at end of input
make: *** [src/parser_issue.o] Error 1
with --save-temps I see that
-DDEFINED:
gcc => #define DEFINED 1
CDT Parse log => DEFINED=
-DDEFINED="":
gcc => #define DEFINED
CDT Parse log => DEFINED=""
Presumably make / the shell is resolving an empty quotes to nothing, so the compiler isn't seeing this -DDEFINED=. The workaround is to set DEFINED= in the build settings page. Unfortunately the Paths & Symbols page has two boxes: Name + Value. If you leave Value blank it just does -DDEFINED which is interpreted as -DDEFINED=1. Even with -DDEFINED=, exporting this setting doesn't seem to work right. You end up with -DDEFINED again. FWIW, I managed to work round the problem by setting DEFINED to ${env_var:NULL}
(NULL is not set to anything). This gets propagated through the project references okay, and I end up with 'DDEFINED= on the command line rather than just -DDEFINED.
(In reply to comment #0) > There seems to be an issue in the way -Ds in quotes are passed to the parser. See also more issues related to quoting in bug 309158 (In reply to comment #3) > FWIW, I managed to work round the problem by setting DEFINED to ${env_var:NULL} That's a good one |
There seems to be an issue in the way -Ds in quotes are passed to the parser. Steps to reproduce: 1) Create HelloWorld program int main(void) DEFINED { puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */ return EXIT_SUCCESS; } 2) Add define (in build settings, or paths and symbols) DEFINED -> "" 3) Build the app make all Building file: ../src/parser_issue.c Invoking: GCC C Compiler gcc -DDEFINED="" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/parser_issue.d" -MT"src/parser_issue.d" -o"src/parser_issue.o" "../src/parser_issue.c" Finished building: ../src/parser_issue.c Syntax error shown in the UI. Adding "#define DEFINED" to the source file resolves the issue local to the file.