为什么 VS2017 会警告 "Function definition not found" 函数前向声明为输入 typedef' 但定义为原始?

Why does VS2017 warn "Function definition not found" for functions forward declared with input typedef'd but defined with original?

我试图模仿 CURL 似乎如何在内部实现 CURL 结构 Curl_easy,这样 API 用户使用结构名称 CURL,并且 API 在内部将 CURL 引用为 Curl_easy.

这是通过

typedef struct Curl_easy CURL

在curl/curl.h 然后有

CURL_EXTERN CURL *curl_easy_init(void);

struct Curl_easy *curl_easy_init(void)

分别在curl/easy.h和easy.c中。

所以我复制了这个想法并做了一个应该做同样事情的小例子:

typedef struct IntStruct IS;

IS* initializeIS();
void countUpIS( IS* is );

struct IntStruct
{
    int i;
};

IntStruct* initializeIS()
{
    IntStruct* is = new IntStruct;
    is->i = 0;
    return is;
}

void countUpIS( IntStruct* is )
{
    is->i++;
}

#include <iostream>
using namespace std;

int main( int argc, char* argv[] )
{
    IS* is = initializeIS();
    countUpIS( is );
    cout << is->i << endl;

    return 0;
}

这使得那些函数 initializeIS() 和 countUpIS() 的用户使用结构名称 "IS",但这些函数的开发人员将其称为 "IntStruct"。

此代码编译并运行良好,但 VS2017 似乎将 countUpIS 绿色下划线显示为 "Function definition for 'countUpIs' not found"。

对为什么会这样有任何见解吗?一些完全合法但在 VS2017 中没有很好解析的东西?

Some programmer dude provided the answer in :

The parser used by IntelliSense inside Visual Studio is not the same parser used by the actual compiler. Therefore there are cases (like your apparently) where the two differs.