J.D.Coleman@newcastle.ac.uk (Julian Coleman) (02/27/91)
We are having problems getting gcc to compile a simple c++ program. This is the program : ----------------------------------------------------------------------- // File hello.c #include <stream.h> main () { cout << "hello world"; } ----------------------------------------------------------------------- This is the compile sequence for this program : ----------------------------------------------------------------------- C:\C\SOURCE\GCC\TEST>gcc -v -o hello hello.c gcc version 1.37.1 cpp -v -undef -D__GNUC__ -Dunix -Di386 -D__unix__ -D__i386__ hello.c c:/pdsoft/ gcpp/tmp/ccAA_AAA.cpp GNU CPP version 1.37.1 c:/pdsoft/gcpp/inc/_File.h:50: unterminated string or character constant c:/pdsoft/gcpp/inc/_File.h:51: unterminated string or character constant c:/pdsoft/gcpp/inc/_File.h:52: unterminated string or character constant c:/pdsoft/gcpp/inc/streambuf.h:97: unterminated string or character constant ----------------------------------------------------------------------- What is wrong ? Thanks for any pointers, Julian +---------------------------+------------------------------------------+ | Julian Coleman | J.D.Coleman@newcastle.ac.uk | +---------------------------+------------------------------------------+ | Department of Surveying, University of Newcastle upon Tyne | | Newcastle upon Tyne, NE1 7RU, England. +44 91 222 6739 | +----------------------------------------------------------------------+ | "Is it safe?" | | "Oh yes, *it's* perfectly safe, it's just *us* who are in trouble!" | | Hitch Hikers' Guide To The Galaxy - Douglas Adams | +----------------------------------------------------------------------+
av@kielo.uta.fi (Arto V. Viitanen) (03/01/91)
>>>>> On 27 Feb 91 14:53:41 GMT, J.D.Coleman@newcastle.ac.uk (Julian Coleman) said:
Julian> We are having problems getting gcc to compile a simple c++ program.
Julian> This is the compile sequence for this program :
Julian> -----------------------------------------------------------------------
Julian> C:\C\SOURCE\GCC\TEST>gcc -v -o hello hello.c
I noticed, that dj's gcc suppoces c++ programs extension to be .cc, so try
to rename your program to hello.cc .
--
Arto V. Viitanen email: av@kielo.uta.fi
University Of Tampere, av@ohdake.cs.uta.fi
Finland
veit@du9ds3.uni-duisburg.de (Holger Veit) (03/01/91)
In <1991Feb27.145341.18701@newcastle.ac.uk> J.D.Coleman@newcastle.ac.uk (Julian Coleman) writes: >We are having problems getting gcc to compile a simple c++ program. >This is the program : >----------------------------------------------------------------------- >// File hello.c [...the well known C++ hello world follows, everybody knows...] >This is the compile sequence for this program : >C:\C\SOURCE\GCC\TEST>gcc -v -o hello hello.c >gcc version 1.37.1 > cpp -v -undef -D__GNUC__ -Dunix -Di386 -D__unix__ -D__i386__ hello.c c:/pdsoft/ >gcpp/tmp/ccAA_AAA.cpp >GNU CPP version 1.37.1 >c:/pdsoft/gcpp/inc/_File.h:50: unterminated string or character constant >c:/pdsoft/gcpp/inc/_File.h:51: unterminated string or character constant >c:/pdsoft/gcpp/inc/_File.h:52: unterminated string or character constant >c:/pdsoft/gcpp/inc/streambuf.h:97: unterminated string or character constant >----------------------------------------------------------------------- >What is wrong ? > | Julian Coleman | J.D.Coleman@newcastle.ac.uk | Same problem as already replied before. The compiler driver GCC.EXE requires the extensions .c for C-Sources .cc for C++ - Sources .s for AS - Sources .i preprocessor output other extensions are passed to the linker, e.g. .o, .a, .cpp (!), .c++ (!) To your problem: rename hello.c to hello.cc and try again. Holger Veit -- | | / Holger Veit | INTERNET: veit@du9ds3.uni-duisburg.de |__| / University of Duisburg | BITNET: veit%du9ds3.uni-duisburg.de@UNIDO | | / Fac. of Electr. Eng. | UUCP: ...!uunet!unido!unidui!hl351ge | |/ Dept. f. Dataprocessing |
crc@stl.stc.co.uk (Clive Carter) (03/13/91)
Julian Coleman writes: We are having problems getting gcc to compile a simple c++ program. This is the program : ----------------------------------------------------------------------- // File hello.c #include <stream.h> main () { cout << "hello world"; } ----------------------------------------------------------------------- This is the compile sequence for this program : ----------------------------------------------------------------------- C:\C\SOURCE\GCC\TEST>gcc -v -o hello hello.c gcc version 1.37.1 cpp -v -undef -D__GNUC__ -Dunix -Di386 -D__unix__ -D__i386__ hello.c c:/pdsoft/ gcpp/tmp/ccAA_AAA.cpp GNU CPP version 1.37.1 etc........... -------------------oOo------------------- Julian, I compiled and executed this program with no trouble. The problem is caused by telling gcc to compile a C program rather than a C++ one. What you should use is: // File hello.cc and C:\C\SOURCE\GCC\TEST>gcc -v -o hello hello.cc ----- Regards, Clive Carter (crc@stl.stc.co.uk (+44) 279 429531 ext3646)
J.D.Coleman@newcastle.ac.uk (Julian Coleman) (03/13/91)
Thanks to all who replied regarding the problem with GCC and c++ files.
As was pointed out, GCC determines the file type by looking at it's extension.
Giving a c++ file the extension '.cc' solves the problem we had with this.
Thanks again,
Julian
+---------------------------+------------------------------------------+
| Julian Coleman | J.D.Coleman@newcastle.ac.uk |
+---------------------------+------------------------------------------+