Vscode-cpptools: IntelliSense include error on Mac: cannot open source file "endian.h"

Created on 28 Jun 2017  路  11Comments  路  Source: microsoft/vscode-cpptools

  • VSCode Version: Code 1.13.1 (379d2efb5539b09112c793d3d9a413017d736f89, 2017-06-14T18:13:05.928Z)
  • OS Version: Darwin x64 16.6.0
  • Extensions:

|Extension|Author|Version|
|---|---|---|
|latex-workshop|James-Yu|2.7.0|
|python|donjayamanne|0.6.5|
|code-runner|formulahendry|0.6.24|
|cpptools|ms-vscode|0.12.0|
|java|redhat|0.6.0|;


I've been playing with the IntelliSense feature by setting C_Cpp.intelliSenseEngine as Default. However, I found there's a green squiggly line under my first #include, saying "endian.h" file cannot be opened.

Screenshot:

perkyfarflunghippopotamus-size_restricted

Steps to Reproduce:

  1. Write a simple C++ file under an empty directory, open it in VSCode.
  2. Set the engine as Default, then the error above appears.
Language Service

Most helpful comment

@Leedehai Can you search for endian.h, math.h, and time.h on your machine? If you're using those to build, it has to be somewhere on your build path. You can use clang -v -E -x c++ - < /dev/null to find build paths used by clang internally.

All 11 comments

You need to add the path to endian.h. I believe it's at /usr/include/i386. We will consider adding the path to the default macOS includePath if it exists.

Thanks, I also found files under /usr/include/machine are wrappers of files under the i386 directory. Adding either one could resolve the problem.

Thanks for the hint.. Same problem here.
But on my Mac, neither /usr/include/i386/ nor /usr/include/machine exists. IntelliSense also complains about missing math.h and time.h
I can compile C and C++ code using clang on my Mac, though.

@Leedehai Can you search for endian.h, math.h, and time.h on your machine? If you're using those to build, it has to be somewhere on your build path. You can use clang -v -E -x c++ - < /dev/null to find build paths used by clang internally.

@sean-mcmanus Thanks for the reply. I searched - time.h and math.h are found - they came with mac's Xcode IDE. I use clang to build small programs in command-line, but clang's default include paths contain Xcode's files.
However, endian.h is missing. Then I tried to use clang to compile a test.c that includes one header - \

Edit - I further investigated the IntelliSense's error message about missing "endian.h" - it turns out that the error originates from a "#include \

@Leedehai It sound like you might be missing something in your "defines" list. I'd recommend opening up the files that are claiming to require endian.h and look for an #ifdef that is missing. You could also try creating a dummy endian.h file, but if our IntelliSense engine is actually trying to use stuff from that file, then it might complain about the endian.h declarations being missing.

I get the same error as @Leedehai

@AndersenTobias I created a fake "endian.h" in the include directory and problem solved. I know it is far from ideal, though.

I have the same issue. It seems to me that VSCode reads the wrong string file. Instead of one of the files from my includePath (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string), it seems to read /usr/include/c++/4.2.1/string, which is not defined in my includePath.

@bobbrow would it be possible to re-open this issue?

This disappeared for me with the latest version of VS Code.

The root cause for this is being tracked by new issue: #1005. Add "__LITTLE_ENDIAN__" to your "defines" array in c_cpp_properties.json and you won't need to add a path to "endian.h".

Was this page helpful?
0 / 5 - 0 ratings