vscode-cpptools
vscode-cpptools copied to clipboard
Add IntelliSense mode and support for emscripten / web assembly
Environment
- OS and version: macOS 12.5
- VS Code: 1.70.2
- C/C++ extension: 1.11.5
- GDB / LLDB version: N/A
Bug Summary and Steps to Reproduce
IntelliSense does not work for Emscripten. C++ Tool will query the default compiler target, but would not recognize it:
Querying compiler's default target using command line: "/Users/tommyli/Documents/emscripten-core/emsdk/upstream/emscripten/em++" -dumpmachine
Compiler returned default target value: wasm32-unknown-emscripten
Unhandled default compiler target value detected: wasm32-unknown-emscripten
And then it will go on and query the headers with the wrong target specified (in this case, ARM):
Compiler query command line: /Users/tommyli/Documents/emscripten-core/emsdk/upstream/emscripten/em++ -std=gnu++17 --target=aarch64-arm-none-eabi -Wp,-v -fno-blocks -E -dM -x c++ /dev/null
This would cause Emscripten's clang
to use the wrong relative sysroot directory for header search, thus breaking IntelliSense.
tommyli@HOST ~ % em++ -std=gnu++17 --target=aarch64-arm-none-eabi -Wp,-v -fno-blocks -E -dM -x c++ /dev/null
clang -cc1 version 16.0.0 based upon LLVM 16.0.0git default target x86_64-apple-darwin21.6.0
ignoring nonexistent directory "/Users/tommyli/Documents/emscripten-core/emsdk/upstream/emscripten/cache/sysroot/usr/local/include"
ignoring nonexistent directory "/Users/tommyli/Documents/emscripten-core/emsdk/upstream/emscripten/cache/sysroot/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/Users/tommyli/Documents/emscripten-core/emsdk/upstream/emscripten/cache/sysroot/include/SDL
/Users/tommyli/Documents/emscripten-core/emsdk/upstream/emscripten/cache/sysroot/include/compat
/Users/tommyli/Documents/emscripten-core/emsdk/upstream/lib/clang/16.0.0/include
End of search list.
Dropping --target
would make cm++
finding the sysroot headers correctly:
tommyli@HOST ~ % em++ -std=gnu++17 -Wp,-v -fno-blocks -E -dM -x c++ /dev/null
clang -cc1 version 16.0.0 based upon LLVM 16.0.0git default target x86_64-apple-darwin21.6.0
ignoring nonexistent directory "/Users/tommyli/Documents/emscripten-core/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1"
ignoring nonexistent directory "/Users/tommyli/Documents/emscripten-core/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
/Users/tommyli/Documents/emscripten-core/emsdk/upstream/emscripten/cache/sysroot/include/SDL
/Users/tommyli/Documents/emscripten-core/emsdk/upstream/emscripten/cache/sysroot/include/compat
/Users/tommyli/Documents/emscripten-core/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1
/Users/tommyli/Documents/emscripten-core/emsdk/upstream/lib/clang/16.0.0/include
/Users/tommyli/Documents/emscripten-core/emsdk/upstream/emscripten/cache/sysroot/include
Debugger Configurations
N/A
Debugger Logs
N/A
Other Extensions
No response
Additional Information
No response
Hi @heshuimu . The C/C++ Extension currently supports IntelliSense modes for x86, x64, ARM, and ARM64. When an unrecognized target is encountered, it will fall back to the IntelliSense mode associated with the host system.
We could use this issue to track adding IntelliSense support for emscripten.
If you are using a basic c_cpp_properties.json
configuration (and not compile-commands.json, or a custom configuration provider), you could disable compiler querying by setting your compilerPath
to ""
, and include any needed compiler defines and includes in the defines
and includes
fields.
@Colengms Thank you for the explanation. I understand the behavior now.
My question is: for each supported IntelliSense mode, does C++ Extension do something special for each mode? My expectation for using the extension is no more than having accurate auto-completion, and I assume it does not depend on a specific IntelliSense mode to work?
Would it make sense to have a generic/fallback mode for the extension to only enable partial features should it encounter a compiler target it does not fully support? Also to pair with it, would it make sense to add a new property in c_cpp_properties.json to allow specifying a compiler target?
@heshuimu Our parser is configured differently for each mode. It may not parse system headers or basic types correctly in certain modes, e.g. long double might have different sizes.
We have an issue tracking a generic mode at https://github.com/microsoft/vscode-cpptools/issues/4653 .
I'm not sure exactly what you mean by a new property to specify a compiler target, i.e. how that differ from our existing intelliSenseMode and compilerPath/Args.
This feature request is being closed due to insufficient upvotes. Please leave a 👍-upvote or 👎-downvote reaction on the issue to help us prioritize it. When enough upvotes are received, this issue will be eligible for our backlog.
This feature request has received enough votes to be added to our backlog.