简体   繁体   English

是否可以让 VsCode Intellisense 感知 C 预处理器生成的源代码?

[英]Is it possible to get VsCode Intellisense to sense against source produced by the C preprocessor?

Say I have a C program that looks something like this...假设我有一个 C 程序,看起来像这样......

#define Pointlike(type) \
    type lat;\
    type lng;
    
typedef struct Point {
    Pointlike(void*)
} Point;

typedef struct {
    Pointlike(int)
} IntPoint;

int main(){

    Point *point = &(Point){.lat = (void*) 0, .lng = (void*) 1};
    IntPoint *intPoint = &(IntPoint){ .lat = 0, .lng = 1 };
    IntPoint *unsafe = (IntPoint*) point;

    return 0;
}

Under my current configuration, VsCode Intellisense does not recognize the fields that would be provided by Pointlike .在我当前的配置下,VsCode Intellisense 无法识别Pointlike提供的字段。

Is there something I'm missing in my config?我的配置中缺少什么吗? I could imagine this is the intended behavior because I wouldn't necessarily expect Intellisense to run the preprocessor by default.我可以想象这是预期的行为,因为我不一定期望 Intellisense 默认运行预处理器。 Is there a way for example to pipe gcc -E into Intellisense to somehow pick up these symbols?有没有办法,例如 pipe gcc -E进入 Intellisense 以某种方式获取这些符号?

In the latest version of C/C++ Intellisense, this appears to work out of the box.在最新版本的 C/C++ Intellisense 中,这似乎开箱即用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C预处理器宏是否可以包含预处理程序指令? - Is it possible for C preprocessor macros to contain preprocessor directives? 是否可以在C中打印预处理器变量? - Is it possible to print a preprocessor variable in C? 是否可以截断 C 预处理器标识符? - Is it possible to truncate C preprocessor identifiers? 在源文件中获取对特定函数的所有调用并生成其他文件(使用C,C ++预处理器或脚本) - Get all calls to specific function in source file and generate other files (using C, C++ preprocessor or scripts) 是否可以将一个预处理器的输入用于C语言中的另一个预处理器? - Is it possible to use one preprocessor's input into another preprocessor in C? 是否可以在C宏中放置预处理器条件? - Is it possible to put a preprocessor conditional inside a C macro? 是否可以在C预处理器中进行部分宏应用/ currying? - Is partial macro application / currying possible in the C preprocessor? 是否可以调用 function 或在 C 预处理步骤中计算? - It is possible to call function or calculate in C preprocessor step? 是否可以通过 C 中的预处理器指令计算斐波那契数列? - Is it possible to calculate Fibonacci sequence by preprocessor directives in C? VSCode C / C ++ Intellisense和Windows特定的库 - VSCode C/C++ Intellisense and Windows specific libraries
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM