为什么即使 header 文件路径在包含路径中,Visual Studio 代码也找不到 `ulong/uint`?

Why Visual Studio Code can't find the `ulong/uint` even if the header file path is in the include path?

我正在尝试让 Intellisense 在 MySQL 源代码上工作,使用 Ubuntu 上的 Visual Studio 代码。

项目需要 libmysqlclient-dev,已安装。

尽管我在 includePath 中包含开发 headers 路径:

        "includePath": [
            "/usr/include/mysql",
            "${workspaceFolder}/include"
        ],

(这是必需的包含的一部分;我添加了很多其他的都无济于事)

无法识别数据类型ulonguint,导致一连串的错误:

identifier "uint" is undefined
identifier "ulong" is undefined
// and so on

这很奇怪,因为我可以看到定义了两种类型:

/usr/include/mysql/my_global.h
177:typedef unsigned int uint;
497:typedef unsigned long   ulong;        /* Short for unsigned long */
504:typedef unsigned long long int ulonglong; /* ulong or unsigned long long */

包含指令存在(示例文件如下):

client/mysqldump.c
43:#include <my_global.h>

我错过了什么?

鉴于源代码中#if#ifdef#ifndef等条件编译特性的复杂使用(有版本here),无关于您的确切环境的特定信息,不可能确切地说您需要做什么。

但是,一般来说,您需要确保您的环境是这样的,即具有相关 typedef 语句的行实际上被 C 预处理器包含在编译的代码中。

有几种方法可以帮助确定这一点。第一,你可以让你的编译器转储它所有的宏。对于 MSVC,请参阅 How to find out cl.exe's built-in macros. Second, you can examine the output of the preprocessed code. For MSVC see How do I see a C/C++ source file after preprocessing in Visual Studio?

由于复杂的 #if... 预处理器指令,当有许多可能的结果时,其中任何一个都可以极大地帮助查看实际编译的代码。