You've just quoted the clang style guide, as in the style guide for the clang source. I'm not working on the clang source, but I'm just trying to build a simple clang program.
After digging around some more, I've found a few other things. I've tried compiling a new c++ hello world (one that doesn't use iostream).
Code:
#include <string>
#include <cstdio>
int main(int argc, char** argv) {
std::string greeting = "Hello World!";
printf("%s\n", greeting.c_str());
return 0;
}
I can compile and run this fine with g++. With clang, I get the following output:
Code:
$ clang++ helloworld2.cpp
helloworld2.cpp:1:10: fatal error: 'string' file not found
#include <string>
^
1 error generated.
I did learn, however, that you can pass the -v flag to clang, and it will display some information as to where the include directories are, etc.
Code:
$ clang++ helloworld2.cpp -v
clang version 2.8 (branches/release_28)
Target: x86_64-redhat-linux-gnu
Thread model: posix
"/usr/bin/clang" -cc1 -triple x86_64-redhat-linux-gnu -S -disable-free -disable-llvm-verifier -main-file-name helloworld2.cpp -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.21.51.0.6 -v -resource-dir /usr/lib/clang/2.8 -ferror-limit 19 -fmessage-length 216 -fexceptions -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/cc-KHG1MA.s -x c++ helloworld2.cpp
clang -cc1 version 2.8 based upon llvm 2.8 hosted on x86_64-redhat-linux-gnu
ignoring nonexistent directory "/usr/include/c++/4.6.0"
ignoring nonexistent directory "/usr/include/c++/4.6.0/x86_64-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.6.0/backward"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.6.0/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/clang/2.8/include
/usr/include
End of search list.
helloworld2.cpp:1:10: fatal error: 'string' file not found
#include <string>
^
1 error generated.
As you can see above, it's looking for the includes in directories that don't exist. So, I went and added the correct /usr/include/c++/4.6.1/ directories, and still got an error:
Code:
$ clang++ helloworld2.cpp -v -I/usr/include/c++/4.6.1 -I/usr/include/c++/4.6.1/x86_64-redhat-linux/ -I/usr/include/c++/4.6.1/backward -I/usr/lib/gcc/x86_64-redhat-linux/4.6.1/
clang version 2.8 (branches/release_28)
Target: x86_64-redhat-linux-gnu
Thread model: posix
"/usr/bin/clang" -cc1 -triple x86_64-redhat-linux-gnu -S -disable-free -disable-llvm-verifier -main-file-name helloworld2.cpp -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.21.51.0.6 -v -resource-dir /usr/lib/clang/2.8 -I /usr/include/c++/4.6.1 -I /usr/include/c++/4.6.1/x86_64-redhat-linux/ -I /usr/include/c++/4.6.1/backward -I /usr/lib/gcc/x86_64-redhat-linux/4.6.1/ -ferror-limit 19 -fmessage-length 216 -fexceptions -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/cc-GZPRH0.s -x c++ helloworld2.cpp
clang -cc1 version 2.8 based upon llvm 2.8 hosted on x86_64-redhat-linux-gnu
ignoring nonexistent directory "/usr/include/c++/4.6.0"
ignoring nonexistent directory "/usr/include/c++/4.6.0/x86_64-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.6.0/backward"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.6.0/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/4.6.1
/usr/include/c++/4.6.1/x86_64-redhat-linux
/usr/include/c++/4.6.1/backward
/usr/lib/gcc/x86_64-redhat-linux/4.6.1
/usr/local/include
/usr/lib/clang/2.8/include
/usr/include
End of search list.
In file included from helloworld2.cpp:1:
In file included from /usr/include/c++/4.6.1/string:41:
In file included from /usr/include/c++/4.6.1/bits/char_traits.h:40:
/usr/include/c++/4.6.1/bits/stl_algobase.h:378:43: error: unexpected type name '_ValueTypeI': expected expression
const bool __simple = (__is_trivial(_ValueTypeI)
^
/usr/include/c++/4.6.1/bits/stl_algobase.h:383:40: error: non-type template argument of type 'bool const' is not an integral constant expression
return std::__copy_move<_IsMove, __simple,
^~~~~~~~
/usr/include/c++/4.6.1/bits/stl_algobase.h:573:43: error: unexpected type name '_ValueType1': expected expression
const bool __simple = (__is_trivial(_ValueType1)
^
/usr/include/c++/4.6.1/bits/stl_algobase.h:578:49: error: non-type template argument of type 'bool const' is not an integral constant expression
return std::__copy_move_backward<_IsMove, __simple,
^~~~~~~~
/usr/include/c++/4.6.1/bits/stl_algobase.h:731:32: error: expected ';' in 'for' statement specifier
for (__decltype(__n + 0) __niter = __n;
^
/usr/include/c++/4.6.1/bits/stl_algobase.h:732:5: error: use of undeclared identifier '__niter'
__niter > 0; --__niter, ++__first)
^
/usr/include/c++/4.6.1/bits/stl_algobase.h:732:20: error: use of undeclared identifier '__niter'
__niter > 0; --__niter, ++__first)
^
/usr/include/c++/4.6.1/bits/stl_algobase.h:732:27: error: expected ')'
__niter > 0; --__niter, ++__first)
^
/usr/include/c++/4.6.1/bits/stl_algobase.h:731:11: note: to match this '('
for (__decltype(__n + 0) __niter = __n;
^
/usr/include/c++/4.6.1/bits/stl_algobase.h:743:32: error: expected ';' in 'for' statement specifier
for (__decltype(__n + 0) __niter = __n;
^
/usr/include/c++/4.6.1/bits/stl_algobase.h:744:5: error: use of undeclared identifier '__niter'
__niter > 0; --__niter, ++__first)
^
/usr/include/c++/4.6.1/bits/stl_algobase.h:744:20: error: use of undeclared identifier '__niter'
__niter > 0; --__niter, ++__first)
^
/usr/include/c++/4.6.1/bits/stl_algobase.h:744:27: error: expected ')'
__niter > 0; --__niter, ++__first)
^
/usr/include/c++/4.6.1/bits/stl_algobase.h:743:11: note: to match this '('
for (__decltype(__n + 0) __niter = __n;
^
12 errors generated.
It appears to me now that there is just something broken about clang++ on Fedora 15.
---------- Post added at 02:00 PM ---------- Previous post was at 01:58 PM ----------
Well something is broken. Just found this:
https://bugzilla.redhat.com/show_bug.cgi?id=729308