简体   繁体   中英

User defined Extension of C++ file for g++ compilation

For some reason, I would like to use an extension .cxy to use as a c++ source code. Say, the filename is abc.cxy . But, my g++ (4.9.2 version) is failing to compile. I am compiling as:

g++ -o abc.oxy abc.cxy

It's complaining as: g++: warning: conn.cxy: linker input file unused because linking not done And, the object file abc.oxy is not being made. Whereas, if I have the extension as .cxx , and compile as:

g++ -o abc.oxy abc.cxx

It's making abc.oxy Am I not allowed to use extension other than .c, .cpp, .cxx ?

Try g++ -o abc.oxy -x c++ abc.cxy

g++ can't deduce the correct language from your custom suffix, and anything that it can't deduce as source, it passes directly to the linker as an object file.

Am I not allowed to use extension other than .c, .cpp, .cxx ?

Not if you want GCC to auto deduce the source language. Conventions are in place so we won't have to be explicit, but you can still use the -x option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM