Summary: | Compiling and linking through compiler driver with '-x c++' fails to link with stream of errors | ||
---|---|---|---|
Product: | gcc | Reporter: | Jeffrey Walton <noloader> |
Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED INVALID | ||
Severity: | normal | CC: | manu |
Priority: | P3 | ||
Version: | 5.1.1 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: |
Description
Jeffrey Walton
2015-08-02 12:26:48 UTC
-x c++ means the input is c++ source no matter what the extension. That -x c++ with .o files are being treated as c++ source and being compiled and that is what is the error message is saying. The .o file is a binary file. (In reply to Andrew Pinski from comment #2) > That -x c++ with .o files are being treated as c++ source and being compiled > and that is what is the error message is saying. The .o file is a binary > file. Oh, thanks Andrew. That explains it. Sorry about that. Andrew/Everyone(In reply to Andrew Pinski from comment #1) > -x c++ means the input is c++ source no matter what the extension. Sorry to revisit this... According to the GCC docs, GCC should not be changing the input file type of object files. See "-x language" topic at https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#Overall-Options. If the document is accurate and I am parsing it correctly, then -x only applies to: c c-header cpp-output c++ c++-header c++-cpp-output objective-c objective-c-header objective-c-cpp-output objective-c++ objective-c++-header objective-c++-cpp-output assembler assembler-with-cpp ada f77 f77-cpp-input f95 f95-cpp-input go java In the end, I know you are right. So I guess that explains why I thought -x applied to source files, and not object files. "Specify explicitly the language for the following input files (rather than letting the compiler choose a default based on the file name suffix). This option applies to all following input files until the next -x option. Possible values for language are:" "Following input files" seems confusing the first time I read it but the second time I read it, I read it as the input files that are after the -x option rather than the types listed below. Hopefully that makes better sense. (In reply to Jeffrey Walton from comment #4) > Andrew/Everyone(In reply to Andrew Pinski from comment #1) > If the document is accurate and I am parsing it correctly, then -x only > applies to: What it is trying to say is "the effect of -x only applies to the files that appear in the command line on the right side of it and up to the next -x option". The description of -x none talks of "subsequent files". I'm not sure how to best phrase it, but suggestions are welcome in gcc-patches@ (with CC to the doc maintainers, Sandra is quite good a phrasing things clearly). |