[cfe-dev] clang unable to build example C file

Török Edvin edwintorok at gmail.com
Wed Oct 10 12:49:39 PDT 2007


I tried to compile a simple program with clang, but it failed.
I am using clang r42834, and llvm r42834.
I also tried clang r42834 with llvm 2.1 but build failed because of
some prototype mismatch.

Which version of clang should I usem and what version of llvm does it
compile with?

$ cat t.c
int main() { return 0; }

$ clang t.c

<predefines>:1:2: error: invalid preprocessing directive
#define __STDC__ 1
<predefines>:2:2: error: invalid preprocessing directive
#define __STDC_VERSION__ 199901L
<predefines>:3:2: error: invalid preprocessing directive
#define __STDC_HOSTED__ 1
<predefines>:86:2: error: invalid preprocessing directive
#define __PIC__ 1
85 diagnostics generated.

Also the preprocessor acts strange (it gives same errors as above)
$ clang t.c -E 2>/dev/null
# 1 "t.c" 1
# 0 "t.c"
# 1 "<predefines>" 1

def  iltin_va_list;
# 1 "t.c" 2
 () { rn 0; }

Is that text truncation due to the errors above, or signs of miscompilation?

Some more info:
$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr
--disable-werror --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.2.1 (Debian 4.2.1-5)

$ /lib/libc.so.6
GNU C Library stable release version 2.6.1, by Roland McGrath et al.
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
Compiled by GNU CC version 4.2.1 (Debian 4.2.1-5).
Compiled on a Linux >>2.6.17-2-vserver-amd64<< system on 2007-09-17.
Available extensions:
        crypt add-on version 2.1 by Michael Glad and others
        GNU Libidn by Simon Josefsson
        Native POSIX Threads Library by Ulrich Drepper et al
For bug reporting instructions, please see:

$ ld -v
GNU ld (GNU Binutils for Debian) 2.18


More information about the cfe-dev mailing list