Eclipse Luna CDT: What is a header variant?

codan, eclipse, eclipse-cdt

Solution

Let's say you have header `a.h` like this:

#pragma once

#ifndef SYMBOL
#define SYMBOL int
#endif

struct S
{
  SYMBOL sym;
};

And now if you include your header like this:

struct UserSymbol
{
  int i, j, k;
};

#define SYMBOL UserSymbol

#include "a.h"

S var;

int main()
{
  var.sym.i = 123;
  return 0;
}

then Eclipse CDT may not to recognize `sym.i`.

You may have more complex examples with deeper nested inclusions or so on.

EDIT:

But if you include the `a.h` to the "Index all variants of specific headers" list or check "Index all header variants" Eclipse will build several variants of the `a.h` indexes and will "know" that you have defined the your specific `SYMBOL`.

Problem

I am having difficulty getting the Eclipse Indexer (Codan) to recognize certain data declarations in header files. There is a new preference to Index all header variants, but little explanation as to what this means. Enabling the preference seems to fix the problem. But I still would like to know what the preference does exactly.

Original source