FreeBSD clang++ -x c++ bug
$ clang++ -v FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512 Target: x86_64-unknown-freebsd10.2 Thread model: posix Selected GCC installation:
clang++ -x c++ -c test-function.c clang++ -o test-x_cpp test-x_cpp.c test-function.o clang++: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated clang++ -ferror-limit=1 -x c++ -o test-x_cpp test-x_cpp.c test-function.o test-function.o:1:1: error: expected unqualified-id ELF ^ test-function.o:1:9: warning: null character ignored [-Wnull-character] ELF ^ test-function.o:1:10: warning: null character ignored [-Wnull-character] ELF ^ ... >40 null-character-ignored messages follow ^ fatal error: too many errors emitted, stopping now [-ferror-limit=] 47 warnings and 2 errors generated. *** Error code 1 Stop. make: stopped in /home/dw/src/misc/clang_x_cpp_bug
Hubert Drogosz 2016-02-21 13:08:29 UTC It seems to me that it isn't a bug. For me clang does what it should do. Taking from clang man page: -x
Treat subsequent input files as having type language. So for me it means that it should treat every file after -x option as file of this type. As you're passing object file (test-function.o) after -x c++ option, it tries to interpret this file like c++ source file, and it fails. I think you should compile it this way: clang++ -o test-x_cpp test-function.o -x c++ test-x_cpp.c Unfortunately, there isn't an option to pass object file after using -x option, so object files should be passed before using any -x option.
page updated Feb 21, 2016