Мой код C++ собирается и работает нормально, но я получаю сотни ложноположительных ошибок Intellisense. Одним из примеров является следующий:
Код: Выделить всё
Severity Code Description Project File Line Suppression State Details
Error (active) E0020 identifier "_Float32" is undefined CppProgUbuntu - Linux Debug C:\Users\bsekl\AppData\Local\Microsoft\Linux\HeaderCache\1.0\Ubuntu\opt\gcc-15\include\c++\15.1.0\atomic 1692
Как это исправить, чтобы Intellisense работал правильно и не сообщал о ложноположительных ошибках?
Я отредактировал этот пост, включив в него минимальный воспроизводимый пример, который компилируется и работает успешно. Он состоит из файла C++ «IntellisenseErrorMRE.cpp», файла «CMakeLists.txt» и файла «CMakePresets.json». Они выполняются в проекте CMake в сообществе Visual Studio 2026 в Windows 11, подключенном к WSL:Ubuntu (WSL2). Я использую конфигурацию «Linux Debug», а компилятор — gcc 15.1.0. В файле C++ используется библиотека DataFrame, созданная Хоссейном Мойном (https://github.com/hosseinmoein/DataFrame). Библиотека была установлена в среду Ubuntu и ложноположительные ошибки Intellisense связаны с ней. Этот минимально воспроизводимый пример выдает 909 таких ошибок.
Спасибо всем за помощь. Я рад предоставить любую дополнительную информацию.
IntellisenseErrorMRE.cpp
Код: Выделить всё
// IntellisenseErrorMRE.cpp : Defines the entry point for the application.
//
#include "IntellisenseErrorMRE.h"
#include // Core DataFrame header
#include
using namespace std;
using namespace hmdf; // Datframe library namespace
int main()
{
// Define index type (e.g., unsigned long for numeric indices)
using ULDataFrame = StdDataFrame;
// Prepare data: indices and columns (must be same size)
std::vector indices = { 1, 2, 3, 4, 5 };
std::vector col1 = { 10, 20, 30, 40, 50 };
std::vector col2 = { 1.1, 2.2, 3.3, 4.4, 5.5 };
// Create the DataFrame and load data
ULDataFrame df;
df.load_data(std::move(indices),
std::make_pair("Col1", col1),
std::make_pair("Col2", col2));
// Output the DataFrame to console
df.write(std::cout);
return 0;
}
Код: Выделить всё
# CMakeList.txt : Top-level CMake project file, do global configuration
# and include sub-projects here.
#
cmake_minimum_required (VERSION 3.20)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Enable Hot Reload for MSVC compilers if supported.
if (POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$")
endif()
project ("IntellisenseErrorMRE")
# Include sub-projects.
add_subdirectory ("IntellisenseErrorMRE")
find_package(DataFrame CONFIG REQUIRED)
target_link_libraries(IntellisenseErrorMRE PRIVATE DataFrame::DataFrame)
Код: Выделить всё
// CMakePresets.json
{
"version": 3,
"configurePresets": [
{
"name": "windows-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "x64-debug",
"displayName": "x64 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-release",
"displayName": "x64 Release",
"inherits": "x64-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x86-debug",
"displayName": "x86 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x86-release",
"displayName": "x86 Release",
"inherits": "x86-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "linux-debug",
"displayName": "Linux Debug",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"vendor": {
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
}
}
},
{
"name": "macos-debug",
"displayName": "macOS Debug",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"vendor": {
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
}
}
}
]
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... io-communi
Мобильная версия