By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,435 Members | 1,414 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,435 IT Pros & Developers. It's quick & easy.

does the file extension matter how it's compiled?

P: n/a
I have a file, say test.c and I want to compile is and I happen to look and
it appears to be compiled like a C++ file.
So does it matter is the file extension where to written as test.cpp
Dec 28 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
smnoff wrote:
I have a file, say test.c and I want to compile is and I happen to look and
it appears to be compiled like a C++ file.
So does it matter is the file extension where to written as test.cpp
This depends on the compiler, but since it is compiled as C++ code even
with a .c file extension -- your message is not very clear, but this is
what you appear to be saying -- apparently the file extension does not
matter for yours.

Dec 28 '06 #2

P: n/a
On Thu, 28 Dec 2006 16:59:29 -0600, smnoff wrote
(in article <b%*****************@newsfe19.lga>):
I have a file, say test.c and I want to compile is and I happen to look and
it appears to be compiled like a C++ file.
So does it matter is the file extension where to written as test.cpp
I'm not sure I understand your question, but my guess is you want to
know if source code will be compiled differently based upon the
filename being changed from test.c -test.cpp (or vice versa).

Several compilers I've used on various platforms will change their
compilation behavior based upon that. Source files with a .cpp
"extension" in those environments will compile as if the code is C++,
even if that is not your original intent.

IIRC there is nothing in the C standard that describes that behavior.
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw

Dec 28 '06 #3

P: n/a
smnoff a écrit :
I have a file, say test.c and I want to compile is and I happen to look and
it appears to be compiled like a C++ file.
So does it matter is the file extension where to written as test.cpp

It depends on the compiler, as people have already said.
Many compilers have an option that allow to force the
type of language they will compile, when they are
multi-language compilers.

Other compilers compile just one language, so they ignore
the suffix of the source code.

Dec 29 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.