Forcing C++ compiler to run as C compiler?

Using GNU GCC compiler, what flag can I use? I tried -std=gnu89, but it didn't work.
Isn't GCC a C compiler by default, and you have to specify you want C++ explicitly?
Name the source file with a .c extension and use gcc (instead of g++).
man gcc

It's all in there. :)
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
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
stereoMatching: This doesn't really have anything to do with what you're talking about.

Just wondering if there was an option like this.

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?
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).
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
Topic archived. No new replies allowed.