htwsaar
HTW des Saarlandes       Fakultät IngWi       Prof. Dr.-Ing. Damian Weber       FreeBSD clang++ -x c++ bug

FreeBSD clang++ -x c++ bug

Sun Jan 17 15:20:08 CET 2016

Abstract
Seems I have found a clang++ bug if called with -x c++.
To reproduce

Discussion

Solution
(partially, because it does not resolve the misunderstanding of the error message about "unqualified-id")
 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