ARTICLE AD BOX
In Visual Studio Code, I get the following errors while using the following code.
#include <iostream> // Included header iostream is not used directly (fix available)clangdunused-includes int main() { std::cout << "Hello, world!" << std::endl; // No member named 'cout' in namespace 'std'clang(no_member) No member named 'endl' in namespace 'std'clang(no_member) }For context here:
I use Windows 10 21H2 I use "g++" msys2 as a compiler, and clangd for the language server on visual studio code (I've also tried and had issues with IntelliSense)Now, here's the configuration I've set up while trying to fix the issues
User settings (VS Code):
{ "clangd.path": "c:\\Users\\soul\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\22.1.0\\clangd_22.1.0\\bin\\clangd.exe", "C_Cpp.autocompleteAddParentheses": true, "C_Cpp.default.cppStandard": "c++17", "C_Cpp.default.cStandard": "c99", "C_Cpp.default.includePath": [ "C:\\msys64\\mingw64\\include\\**" ], "C_Cpp.default.intelliSenseMode": "windows-gcc-x64", "C_Cpp.intelliSenseEngine": "disabled", "makefile.configureOnOpen": true }.vscode/settings.json:
{ "terminal.integrated.profiles.windows": { "PowerShell": { "source": "PowerShell", "icon": "terminal-powershell" }, "Command Prompt": { "path": [ "${env:windir}\\Sysnative\\cmd.exe", "${env:windir}\\System32\\cmd.exe" ], "args": [], "icon": "terminal-cmd" }, "Git Bash": { "source": "Git Bash" }, "MSYS2": { "path": "C:\\msys64\\usr\\bin\\bash.exe", "args": [ "--login", "-i" ], "env": { "MSYSTEM": "MINGW64", "CHERE_INVOKING": "1" } } }, "clangd.fallbackFlags": [ "-I${workspaceFolder}/include", "-IC:/msys64/mingw64/include", "-IC:/msys64/mingw64/include/c++/15.2.0" ] }.vscode/c_cpp_properties.json:
{ "configurations": [ { "name": "Win32", "includePath": [ "${workspaceFolder}/include/**", "C:\\msys64\\mingw64\\include\\**", "C:\\msys64\\mingw64\\include\\c++\\15.2.0\\**" ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], "browse": { "limitSymbolsToIncludedHeaders": true, "databaseFilename": "" }, "cppStandard": "c++17" } ], "version": 4 }.clangd:
CompileFlags: Add: # - '--query-driver=C:\msys64\mingw64\g++.exe' # - '-std:c++latest' - "-IC:/msys64/mingw64/include" - "-I${workspaceFolder}/include" - "-IC:/msys64/mingw64/include/c++/15.2.0"Makefile:
CXX = g++ CC = gcc # -I. (current dir) and -I./include (for glad headers) CXXFLAGS = -Wall -O2 -I./include CFLAGS = -Wall -O2 -I./include # Link against GLFW and Windows system libs LDFLAGS = -lglfw3 -lopengl32 -lgdi32 -luser32 -lkernel32 # Include both your C++ code and the GLAD C source SRCS = src/main.cpp src/glad.c TARGET = glGame all: $(TARGET) $(TARGET): $(SRCS) $(CXX) $(CXXFLAGS) $(SRCS) -o $(TARGET) $(LDFLAGS) clean: rm -f $(TARGET).exeSomebody in the comments suggested me to append the extensions I use:
C/C++ by Microsoft C/C++ DevTools by Microsoft C/C++ Extension Pack by Microsoft C/C++ Themes by Microsoft clangd by LLVM CMake Tools by Microsoft Makefile Tools by Microsoft