clang -xc++ foo.o

clang -xc++ -c 1.c 2.c

Jay K via llvm-dev <llvm-dev@lists.llvm.org> writes:

clang -xc++ -c 1.c 2.c

clang -xc++ main.c 1.o 2.o
1.o:1:1: error: source file is not valid UTF-8

Would be nice, albeit I realize kinda proby/non-deterministic/big, if
.o files were recognized and -xc++ did not apply to them.

The -x flags only apply to files later on the command line than they
are, so this works:

clang -xc++ -c 1.c 2.c
clang 1.o 2.o -xc++ main.c

You may also be able to switch back to autodetection with -xnone, though
I haven't tried this:

clang -xc++ -c 1.c 2.c
clang -xc++ main.c -xnone 1.o 2.o

Easier said than done, given the layers of build system (automake). :frowning:

  • Jay

clang -xc++ -c 1.c 2.c

clang -xc++ main.c 1.o 2.o
1.o:1:1: error: source file is not valid UTF-8

Would be nice, albeit I realize kinda proby/non-deterministic/big, if .o files were recognized and -xc++ did not apply to them.

It would be nice, and can possibly be generalized to say:

-xc++:.c (apply -xc++ to .c files going forward)

-xnone:.o (prevent the effects of a previous -x from applying to .o files going forward)