compile C code in G++
Hi,
I have some code that is embraced by extern "C" it compiles okay under gcc, but gives several errors when compiled under g++. Any ideas? Thanks Jack |
If it compiles fine with gcc, why use g++?
At uni, we compile our C code with: gcc -Wall source.cpp |
That's the opposite of what I'd expect. The extern "C" is C++ syntax, so gcc should consider it a syntax error. The gcc front end will also compile the file as C++ if the file has a .cc or .cpp extension.
What exactly is the error message? Mike |
Because the large part of our project is written in C++, but there is certain aspect that we could not figure out. So we need to use some C code...
Thanks Jack |
Quote:
|
Hi, I see the faulty statement
I defined AC_PROG_CC and AC_PROG_CXX so some code did not compile What i want is gcc instead of g++ when I deleted that line, it says C++ code seen, but no AC_PROG_CXX was seen, and told me to add AC_PROG_CXX to configure.in which was not what I wanted. Thanks Jack |
I am dealing with classes and objects here. Can we use gcc instead of g++?
Thanks Jack |
I wrote a small application that tried to integrate g++ and gcc code together to no avail.
#include <stdio.h> class hello { public: hello() { } ~hello(); public: void say_hello(void); }; void hello::say_hello(void) { printf ("Hello\n"); } int main (int argv, char *argv[]) { hello h = new hello(); h->say_hello(); return 0; } Thanks Jack |
The above code doesn't work with gcc.
|
When I used gcc for our already-built code, the system forced us to use g++!
:( Jack |
Man, gcc does not compile C++ code. Just try to integrate the C code in the C++ compiler.
|
Thanks primo,
I tried that before But some APIs like read and write are not recognised by the g++ compiler Jack |
The error mess was
socket.cpp:86: error: 'read' was not declared in this scope |
But gcc was okay (as a standalone test)
|
I meant gcc in native c mode
|
All times are GMT -5. The time now is 09:00 AM. |