Skip to content

Instantly share code, notes, and snippets.

@wayou
Last active July 17, 2023 07:00
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wayou/59f3a8e4fbab050fbb32e94dd9582660 to your computer and use it in GitHub Desktop.
Save wayou/59f3a8e4fbab050fbb32e94dd9582660 to your computer and use it in GitHub Desktop.
setup emscripten for vscode intelli sense

install emscripten

$ brew install emscripten

and setup by following the instruction after the installation.

get the location of emscripten header files

compile any file with the -v options, get the pathes in the includes parts.

$ emcc -v test.c
...
#include <...> search starts here:
 /usr/local/Cellar/emscripten/1.38.32/libexec/system/include/libcxx
 /usr/local/Cellar/emscripten/1.38.32/libexec/system/lib/libcxxabi/include
 /usr/local/Cellar/emscripten/1.38.32/libexec/system/include/compat
 /usr/local/Cellar/emscripten/1.38.32/libexec/system/include
 /usr/local/Cellar/emscripten/1.38.32/libexec/system/include/libc
 /usr/local/Cellar/emscripten/1.38.32/libexec/system/lib/libc/musl/arch/emscripten
 /usr/local/Cellar/emscripten/1.38.32/libexec/system/local/include
 /usr/local/Cellar/emscripten/1.38.32/libexec/system/include/SDL
 ...

config vscode

config vscode by setting "C_Cpp.default.includePath" to the pathes above.

instead of include them all, we can just using wildcard ** to match them all.

"C_Cpp.default.includePath": [
    "/usr/local/Cellar/emscripten/1.38.32/libexec/system/**",
]

now the vscode can find #include "emscripten.h" in your C/C++

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment