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.

Bug 256816 - Conditional preprocessing fails when user macros affect system or user header file content
Summary: Conditional preprocessing fails when user macros affect system or user header...
Status: RESOLVED WONTFIX
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 8.1
Hardware: All All
: P3 normal (vote)
Assignee: Alexander Simon
URL:
Keywords:
Depends on: 216611
Blocks:
  Show dependency tree
 
Reported: 2015-11-26 15:12 UTC by marian.golea
Modified: 2015-11-30 12:46 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
internal PP states (9.75 KB, text/plain)
2015-11-26 15:12 UTC, marian.golea
Details
Added the problem.h header file. (55 bytes, text/plain)
2015-11-26 15:14 UTC, marian.golea
Details
internal PP states for the second project (9.74 KB, text/plain)
2015-11-26 15:26 UTC, marian.golea
Details

Note You need to log in before you can comment on or make changes to this bug.
Description marian.golea 2015-11-26 15:12:22 UTC
Created attachment 157510 [details]
internal PP states

The conditional preprocessing of system/user header files is confused when a change of user macros should affect the parsed content of header files.


I reproduced this using NetBeans Dev 201511260002.
Find attached a report of internal PP states.

A. System setup:
I reproduced using Windows x64 and Cygwin x64, but it is something that will most likely also occur on Linux/Mac.

For clearer steps create a simple "problem.h" header file with following content:
#ifdef PROBLEM_MACRO
int  PROBLEM;
#endif

B. Reproduction steps:
0. add "problem.h" header file to a system include path folder that will be used. In my case: (c:\cygwin64\lib\gcc\x86_64-pc-cygwin\4.9.2\include\c++\)
1. create a new sample project "Welcome" for C++ using Cygwin toolchain. remove include statement and all content from main function except for return statement. For more clarity.
2. To reproduce this in 2 scenarios, copy "problem.h" file also to the base folder of the new project.
3. edit Welcome.cc to add: "PROBLEM;" inside main function. Error reported, as expected.
3. under Debug Configuration, C++ Compiler options add a user macro (preprocessor definition) "PROBLEM_MACRO". Press Apply. Error still there, as expected because we did not add a include statement.
4. Now add #include "problem.h" inside Welcome.cc. Error goes away, as expected. Ctrl-click takes us to correct location.
5. Build project, no problems.
6!!. Delete include statement. No error is shown in the IDE.
7!!. Add include statement to point to the system header file: #include <problem.h>. Ctrl-click still takes us to project folder header file.
8. Delete include statement, no error.
9. Build project and see that it fails, as expected. Due to Action Items view related funcitonality, error appears (build error).

10!! Now create a new project, similar to the former one, but do not add any new include statements or user macros. Just add "PROBLEM;" to the main function and notice how no error is being shown.
Comment 1 marian.golea 2015-11-26 15:14:23 UTC
Created attachment 157511 [details]
Added the problem.h header file.

I was not able to attach 2 files when creating the bug. Added the second after. it is the problem.h header file.
Comment 2 marian.golea 2015-11-26 15:26:44 UTC
Created attachment 157512 [details]
internal PP states for the second project

After creating a new project, once the code editor is confused, you can notice how the results of this confusion are also applied to the new project.

Find attached the internal PP states report for this second one.
Comment 3 Vladimir Voskresensky 2015-11-26 17:15:20 UTC
Thanks for the report!
Alexander, could you have a look, please?
Comment 4 Vladimir Voskresensky 2015-11-30 12:46:34 UTC
It is not a bug.