Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 343685

Summary: c header files with #ifdef macros included by mutiple source files are indexed failed
Product: [Tools] CDT Reporter: Tenggui Fu <tenggui_fu>
Component: cdt-indexerAssignee: Project Inbox <cdt-indexer-inbox>
Status: CLOSED DUPLICATE QA Contact: Markus Schorn <mschorn.eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug, malaperle
Version: 8.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Tenggui Fu CLA 2011-04-23 05:53:20 EDT
Build Identifier: 20110319-2305

Suppose there are three files in a C++ project. a "#ifdef #else #endif" macro is contained in the header file "funny.h", 
which is used to preprocess two different structures. The two structures are referenced in two source files "funny1.c" and
"funny2.c" respectively. The code of the three files are as follows. 
After the project is indexed, only one structure can be referenced correctly and the other one is reported "could not be resolved".
I guess that the header files could be parsed only once and only one block between #ifdef and #else or between #else and #endif can
be found by the CDT-indexer.

1st file: funny.h
#ifdef TEST1
typedef struct _test1
{
    int a;
    int b;
}test1;
#else
typedef struct _test2
{
    int c;
    int d;
}test2;
#endif

2nd file: funny1.c
#define TEST1
#include "funny.h"

int funny1(void)
{
    test1 tst;
    tst.a = 0;
    tst.b = 0;

    return 0;
}

3rd file: funny2.c
#include "funny.h"

int funny2(void)
{
    test2 tst;
    tst.c = 0;
    tst.d = 0;

    return 0;
}

Reproducible: Always

Steps to Reproduce:
1. Create a C++ project
2. Add the three files "funny.h", "funny1.c" and "funny2.c" to the project
3. Index the project
Comment 1 Marc-André Laperle CLA 2011-04-23 13:49:31 EDT

*** This bug has been marked as a duplicate of bug 197989 ***