3

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.

ThomasMcLeod
  • 7,603
  • 4
  • 42
  • 80

1 Answers1

3

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.

Serge Roussak
  • 1,731
  • 1
  • 14
  • 28
  • What's `s` in this case? – ThomasMcLeod Apr 14 '15 at 22:16
  • @ThomasMcLeod, Eclipse will think about `sym.i` like about erroneous construction, will emphasize it with wavy red line, will mark it with warning sign and (IMHO this is most important) will not show a hint when you place mouse pointer over the `i` symbol. – Serge Roussak Apr 16 '15 at 06:37
  • But `s` is not defined either. – ThomasMcLeod Apr 16 '15 at 15:28
  • 2
    Why won't Eclipse CDT recognize `sym.i`? The header is included once in the module, and `SYMBOL` is defined before the inclusion. Am I missing something? – ysap Sep 22 '17 at 18:20
  • 1
    Same as @ysap, I do not understand why "Eclipse CDT *may* not to recognize `sym.i`" (and why "may", in which cases "may" is "will"?). In addition to an example I do not understand (although others do, and in particular the OP is satisfied with the answer), I do not see how "What is a header variant?", from the title, is answered. – sancho.s ReinstateMonicaCellio Oct 31 '19 at 04:54