Forcing C++ compiler to run as C compiler?

Mar 23, 2011 at 3:37am
Using GNU GCC compiler, what flag can I use? I tried -std=gnu89, but it didn't work.
Mar 23, 2011 at 4:31am
Isn't GCC a C compiler by default, and you have to specify you want C++ explicitly?
Mar 23, 2011 at 1:00pm
Name the source file with a .c extension and use gcc (instead of g++).
Mar 23, 2011 at 1:40pm
man gcc

It's all in there. :)
Mar 23, 2011 at 5:15pm
Zhuge: I think I am the wrong person to ask. =]

jsmith: Of course, but not what I asked.

moorecm: True, I looked through it, but nothing popped out at me. It is quite long, you know? For easy access: http://linux.die.net/man/1/gcc
Mar 23, 2011 at 5:20pm
Interesting, why are you want to do that?
If you like c, than just write c, please don't write c in c++
It is always a nightmare and a bad habits to write "x language" in "y language"
I saw a lot of guys like that
They like to write c in c++, c in java, c in c#, assembly in c, pascal in c and so on
This always make the code hard to read, maintain, error prone and low efficient

Maybe you have your special reasons for that?
Last edited on Mar 23, 2011 at 5:22pm
Mar 23, 2011 at 6:08pm
stereoMatching: This doesn't really have anything to do with what you're talking about.

Just wondering if there was an option like this.

Mar 23, 2011 at 6:14pm
stereoMatching, I can see how one could 'write c in c++'. How can you write C in Java, C#, etc... (not that I intend to do it: I'm just curious)?

assembly in c


Isn't the inline assembler useful for low level access / fine tuned optimisation?
Mar 23, 2011 at 6:20pm
A C++ compiler is a C++ compiler and a C compiler is a C compiler. You can compile most C code with C++ compilers anyways, and the parts you can't you can still compile with a C compiler and link with a C++ linker(if you wrap your header in an extern "C" block).
Mar 24, 2011 at 3:24am
not that I intend to do it: I'm just curious)?
I mean they never try to understand the benefits and the defects of oop
Never want to realize higher abstraction

Only treat java and c# as some kind of "c with GC"

Isn't the inline assembler useful for low level access / fine tuned optimisation?
Maybe you are right, since I didn't spend my time to decipher the code
Last edited on Mar 24, 2011 at 3:24am
Topic archived. No new replies allowed.