Cmake 项目运行良好。但是智能感知不起作用

Cmake project works well. But intellisense does not work

2017年visual studio正在研究cmake项目,感觉不太行。但是构建和执行效果很好。为什么智能感知不起作用?

project directory(CMakeLists.txt, CMakeSettings.json)

main directory(main.c, CMakeLists.txt)
include directory(myprint.h)
printstatic directory(printstatic.c, CMakeLists.txt)
printshared directory(printshared.c, CMakeLists.txt)

"myprint.h"

#include <stdio.h>

void print_test_static_library();
void print_test_shared_library();

"main.c"

#include "myprint.h"

int main()
{
    for (int ii = 0; ii < 3; ++ii) {
        printf("Hello CMake..................\n");
        print_test_static_library();
        print_test_shared_library();
    }

    return 0;
}

"CMakeLists.txt of main"

cmake_minimum_required (VERSION 3.8)

add_executable (main "main.c")
target_link_libraries(main printstatic printshared)

"printstatic.c"

#include "myprint.h"

void print_test_static_library()
{
    printf("Test Static Library..................\n");
}

"CMakeLists.txt of printstatic"

cmake_minimum_required (VERSION 3.8)

add_library (printstatic "printstatic.c")

"printshared.c"

#include "myprint.h"

void print_test_shared_library()
{
    printf("Test Shared Library..................\n");
}

"CMakeLists.txt of printshared"

cmake_minimum_required (VERSION 3.8)

add_library (printshared SHARED "printshared.c")

"CMakeLists.txt of project"

cmake_minimum_required (VERSION 3.8)

set(CMAKE_C_STANDARD 99)

project ("CMakeProjectTest")

include_directories(${PROJECT_SOURCE_DIR}/include)
add_subdirectory ("printstatic")
add_subdirectory ("printshared")
add_subdirectory ("main")

"CMakeSettings.json"

{
    "configurations": [
        {
            "name": "Linux-Debug",
            "generator": "Unix Makefiles",
            "remoteMachineName": "${defaultRemoteMachineName}",
            "configurationType": "Debug",
            "remoteCMakeListsRoot": "/home/mary/proj/src/${workspaceHash}/${name}",
            "cmakeExecutable": "/usr/local/bin/cmake",
            "buildRoot": "${env.USERPROFILE}\CMakeBuilds\${workspaceHash}\build\${name}",
            "installRoot": "${env.USERPROFILE}\CMakeBuilds\${workspaceHash}\install\${name}",
            "remoteBuildRoot": "/home/mary/proj/build/${workspaceHash}/build/${name}",
            "remoteInstallRoot": "/home/mary/proj/build/${workspaceHash}/install/${name}",
            "remoteCopySources": true,
            "remoteCopySourcesOutputVerbosity": "Normal",
            "remoteCopySourcesConcurrentCopies": "10",
            "remoteCopySourcesMethod": "sftp",
            "remoteCopySourcesExclusionList": [
                ".vs",
                ".git"
            ],
            "rsyncCommandArgs": "-t --delete --delete-excluded",
            "remoteCopyBuildOutput": false,
            "cmakeCommandArgs": "",
            "buildCommandArgs": "",
            "ctestCommandArgs": "",
            "inheritEnvironments": [
                "linux_x64"
            ]
        }
     ]
}

这是针对 ARM 时 Intellisense 中的错误。 You are not the only one.

通过将项目目标切换为 x64 或 x86,Intellisense 应该可以正确地将代码解析为 C99。如果你需要针对ARM,你只需要暂时忽略那些红线。

无论哪种方式,您都可能希望向 Microsoft 提交错误报告。