Bug 365794 - Defined macros from "files to index up-front" are not working with ifdefs
Summary: Defined macros from "files to index up-front" are not working with ifdefs
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-build-managed (show other bugs)
Version: 8.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-06 14:17 EST by Michał L CLA
Modified: 2020-09-04 15:17 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michał L CLA 2011-12-06 14:17:48 EST
Build Identifier: CDT version: 8.0.0.201109151620

Among the indexer options in the project properties (C/C++ General -> Indexer) there is an option to index some files always before indexing any other files ("Files to index up-front"). It can be used in projects like the Linux kernel, where the autoconf.h file is included during compilation of every file (using the gcc -include command line option). 

I discovered, that the files are indexed properly and all symbols from that files are correctly interpreted in all project files. However, if there are some macro definitions in the pre-included file and some of our files in the project use them in conditional compilation directives (like #ifdef-s), then the code is not grayed out properly. The editor grays out code as if nothing was defined in the pre-included header. It is however still possible to search for the declaration of the missing header. 

Please see the steps to reproduce - I think they illustrate the situation much better than the description above.

Please note, that this problem also occurs on the Linux version.

Reproducible: Always

Steps to Reproduce:
1. Create a new C project - select a Makefile project and "Other toolchain"
2. Add a new C source file source.c with the following contents:
#ifdef FOO
	INTEGER a;
#else
	INTEGER b;
#endif
3. Add a new C header file head.h with the following contents:
#define FOO
typedef int INTEGER;
4. Open project properties and go to C/C++ General -> Indexer. Enable project specific settings, uncheck all checkboxes in the Indexer options box and replace "Files to index up-front" with only one file name: head.h
5. Close the project properties
6. Rebuild the index (if needed)

Effect: The line with INTEGER a; is grayed out. Still it is possible to search for the declaration of INTEGER and FOO.
Comment 1 Markus Schorn CLA 2011-12-22 04:35:08 EST
To make that work, the parser needs to be configured with the preincluded files. As far as I know, the managed build does not propagate the setting to the parser (The parser calls IExtendedScannerInfo.getIncludeFiles() to look for such files).
Also, we lack a UI to manually configure preincluded files.