Eclipse Luna CDT: What is a header variant?

筅森魡賤 提交于 2021-02-07 19:47:13

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/27217857/eclipse-luna-cdt-what-is-a-header-variant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!