C++11 freestanding headers not found

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

C++11 freestanding headers not found

Tom Stellard via cfe-dev
Hello everyone,

I've recently discovered the LLVM project and Clang, and I am quite happy with it (nice piece of work!). However, I can't figure why this fails:

$ cat > freestanding.cpp
#include <cstdint>
$ clang -c -std=c++11 -ffreestanding --target=i386-none-elf freestanding.cpp
bug.cpp:1:10: fatal error: 'cstdint' file not found
#include <cstdint>
         ^
1 error generated.
$


Trying to compile a source file that merely includes a C++11 header file with the -ffreestanding flag just fails. The same problem occurs for every C++11 freestanding header (<cstdint>, <cstddef>, <climits>...). However, trying to include the pre-C++11 freestanding headers (<stdint.h>, <stddef.h>, <limits.h>, ...) works just fine. I have also tried different targets.

Any idea? Is this some configuration issue? Or some glitch? I can hardly find any information about this problem, this is why I am asking you people.

Have a nice day,
Thomas

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: C++11 freestanding headers not found

Tom Stellard via cfe-dev
On 12 June 2017 at 13:54, Modulo De Pi via cfe-dev <[hidden email]> wrote:
Hello everyone,

I've recently discovered the LLVM project and Clang, and I am quite happy with it (nice piece of work!). However, I can't figure why this fails:

$ cat > freestanding.cpp
#include <cstdint>
$ clang -c -std=c++11 -ffreestanding --target=i386-none-elf freestanding.cpp
bug.cpp:1:10: fatal error: 'cstdint' file not found
#include <cstdint>
         ^
1 error generated.
$


Trying to compile a source file that merely includes a C++11 header file with the -ffreestanding flag just fails. The same problem occurs for every C++11 freestanding header (<cstdint>, <cstddef>, <climits>...). However, trying to include the pre-C++11 freestanding headers (<stdint.h>, <stddef.h>, <limits.h>, ...) works just fine. I have also tried different targets.

Any idea? Is this some configuration issue? Or some glitch? I can hardly find any information about this problem, this is why I am asking you people.

Clang does not provide an implementation of the freestanding C++ headers; you need a C++ standard library (typically libc++ or libstdc++) installed to provide those. (You also need a C standard library to provide the foo.h headers that the C++ standard library itself depends on.)

For certain C standard library headers, there is an informal arrangement between the C standard library implementation and the compiler that the compiler will provide certain of the headers -- stddef.h, stdarg.h, and a few others (which need or significantly benefit from compiler magic) -- although the compiler's version will often defer to the C stdlib version if it exists. But this does not extend to a complete set of freestanding headers.

If you have a C++ standard library installed, Clang should automatically detect it. If it doesn't, we'd want:

 * the output of clang -v when compiling a C++ source file
 * information about where the standard library was installed

to determine why it wasn't automatically found.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Loading...