I've recently swithed from borland C++ 5.5 to MinGW. When I try to compile a .c file using gcc it compiles fine, but when I try to compile a .cpp file using gcc it produces a bunch of errors with c++ specific constructs. If I compile .cpp files with g++ then it works fine. My question is should not gcc call appropriate compilers based on the file extensions? Why does it work for .c files and not for .cpp files. As far as I knew gcc stands for GNU Compiler Collection and it should invoke appropriate compilers on its own. Why is it acting just like a C only compiler?
Asif_NSU
25
Posting Whiz
Recommended Answers
Jump to Post>As far as I knew gcc stands for GNU Compiler Collection and
>it should invoke appropriate compilers on its own.
It does invoke the appropriate compiler, but gcc doesn't know how to link C++ libraries while g++ does. I'd be willing to bet that the errors you're getting are linker …
Jump to Postcan u plz tell the errors or the code which gives error....does it show
cpp: Usage:... Error
All 8 Replies
Narue
5,707
Bad Cop
Team Colleague
SpS
34
Posting Pro
Asif_NSU
25
Posting Whiz
Narue
5,707
Bad Cop
Team Colleague
kawk
0
Newbie Poster
dwks
149
Posting Whiz in Training
Asif_NSU
25
Posting Whiz
perniciosus
19
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.