Re: help: how to compile c++



In article <carl-09BD7F.20043629052006@xxxxxxxxxxxxxxxxxxxxxxxx>,
Carl Witthoft <carl@xxxxxxxxxxxx> wrote:

HI -- I'm well experienced in programming under unix, but haven't ever
played w/ c++. I have successfully compiled c programs on OSX (using
gcc of course). The problem is my child needs to write stuff in c++
for a professor. Her first try crashed, which is to say gcc didn't
like it.
So: can anyone tell me what I need to set up? Should gcc be able to
handle c++, or do I need to set some switches, or download different
libraries, etc?

Well, I normally don't say it, but since you're someone experienced in
programming on Unix, I think "RTFM" might be in order. "man gcc" is a
great place to start. This kind of thing is the same on Mac OS X as on
any other Unix box.

GCC normally uses the filename extension to decide what language is
likely to be in the file. File "foo.c" will normally be assumed to be C
rather than C++, but "foo.cpp" would be assumed to be C++.

There's also "g++", which is just gcc but with the default language set
to C++ rather than C. Replace "gcc" with "g++" and you may be set.

Finally of course there's gcc's "-x" option, which allows you to specify
any supported language you like regardless of anything else. Name your
C++ file "foo.java" if you like, and the right "-x" flag will make it
work.

--
Tom "Tom" Harrington
Macaroni, Automated System Maintenance for Mac OS X.
Version 2.0: Delocalize, Repair Permissions, lots more.
See http://www.atomicbird.com/
.



Relevant Pages

  • Re: LibTomMath forked [SSE2 addons]
    ... [SNIP - faster] ... I find GCC produces faster code for my mulmods/expmods too. ... Good work, Tom. ... 1st bug in MS win2k source code found after 20 minutes: ...
    (sci.crypt)
  • Re: help: how to compile c++
    ... leaves you digging through gcc man pages and manually searching your ... Tom "Tom" Harrington ...
    (comp.sys.mac.system)
  • Re: Cross compiling with intel-linux
    ... Tom Harrington wrote: ... > I don't think all of Apple's changes to gcc have been accepted back into ... > that'll work on Mac OS X. ... > Tom "Tom" Harrington ...
    (comp.sys.mac.programmer.tools)
  • Re: Prohibited attachment type (was 0xdeadbeef)
    ... > Tom is correct. ... A literal constant defaults to 'int'. ... I did a bit more messing around with GCC and it seems in ...
    (Linux-Kernel)
  • Re: Cross compiling with intel-linux
    ... I don't think all of Apple's changes to gcc have been accepted back into ... that'll work on Mac OS X. ... Tom "Tom" Harrington ... Automated System Maintenance for Mac OS X. ...
    (comp.sys.mac.programmer.tools)