Cmake project works well. But intellisense does not work
我正在Visual Studio 2017中学习cmake项目。它看起来不起作用。但是构建和执行效果很好。为什么智能感知不起作用?
1 2 3 4 | main directory(main.c, CMakeLists.txt) include directory(myprint.h) printstatic directory(printstatic.c, CMakeLists.txt) printshared directory(printshared.c, CMakeLists.txt) |
" myprint.h"
1 2 3 4 | #include <stdio.h> void print_test_static_library(); void print_test_shared_library(); |
" main.c"
1 2 3 4 5 6 7 8 9 10 11 12 13 | #include"myprint.h" int main() { for (int ii = 0; ii < 3; ++ii) { printf("Hello CMake..................\ "); print_test_static_library(); print_test_shared_library(); } return 0; } |
"主要的CMakeLists.txt"
1 2 3 4 | cmake_minimum_required (VERSION 3.8) add_executable (main"main.c") target_link_libraries(main printstatic printshared) |
" printstatic.c"
1 2 3 4 5 6 7 | #include"myprint.h" void print_test_static_library() { printf("Test Static Library..................\ "); } |
" printstatic的CMakeLists.txt"
1 2 3 |
" printshared.c"
1 2 3 4 5 6 7 | #include"myprint.h" void print_test_shared_library() { printf("Test Shared Library..................\ "); } |
" printshared的CMakeLists.txt"
1 2 3 |
"项目的CMakeLists.txt"
1 2 3 4 5 6 7 8 9 10 | 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"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | { "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中的错误。您不是唯一的人。
通过将项目目标切换到x64或x86,Intellisense应该正确地将代码解析为C99。如果需要以ARM为目标,则只需暂时忽略那些红线。
您可以通过两种方式向Microsoft提交错误报告。