Dr. Debasish Jana Dr. Debasish Jana - 1 month ago 10
C++ Question

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

For some reason, I would like to use an extension

to use as a c++ source code. Say, the filename is
. But, my
(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
is not being made.
Whereas, if I have the extension as
, and compile as:

g++ -o abc.oxy abc.cxx

It's making

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.