• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Can I use the g++ compiler with xcode?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can I use the g++ compiler with xcode?


  • Subject: Re: Can I use the g++ compiler with xcode?
  • From: Chris Espinosa <email@hidden>
  • Date: Mon, 7 Jun 2004 23:23:13 -0700

On Jun 7, 2004, at 10:13 PM, Creed Erickson wrote:

On Monday, June 7, 2004, at 08:39  PM, Cath Lawrence wrote:

- I could make gcc point to g++ (seems very obscure, I don't like it)

Don't do that. That class of hackery has a tendency to hurt.


- you can make gcc act like g++ with the right switches (which??)

Use -x <language>, as in:

gcc -x c++ -o hello hello.c

gcc is the GNU Compiler Collection, of which g++ is the C++ compiler. See the g++ man page in Mac OS X:


Note: In Apple's version of GCC, both cc and gcc are actually symbolic links to gcc-3.3, while c++ and g++ are links to g++-3.3, unless the gcc_select(1) command has been used to point them at another compiler version.

       Compiling C++ Programs

C++ source files conventionally use one of the suffixes .C, .cc, .cpp,
.CPP, .c++, .cp, or .cxx; C++ header files often use .hh or .H; prepro-
cessed C++ files use the suffix .ii. GCC recognizes files with these
names and compiles them as C++ programs even if you call the compiler
the same way as for compiling C programs (usually with the name gcc).


However, C++ programs often require class libraries as well as a com-
piler that understands the C++ language---and under some circumstances,
you might want to compile programs or header files from standard input,
or otherwise without a suffix that flags them as C++ programs. You
might also like to precompile a C header file with a .h extension to be
used in C++ compilations. g++ is a program that calls GCC with the
default language set to C++, and automatically specifies linking
against the C++ library. On many systems, g++ is also installed with
the name c++.


When you compile C++ programs, you may specify many of the same com-
mand-line options that you use for compiling programs in any language;
or command-line options meaningful for C and related languages; or
options that are meaningful only for C++ programs.


Just use Xcode. In the majority of cases it will do the right thing. If you really want to put C++ code in a .c file, use the -x option described above

You can also set the Build Rules filetype by filetype in a target with the Target Inspector's Rules pane. You may specify there to use g++ instead of gcc for .c files, but then again, you really will be using the same compiler, really.

Chris Espinosa
Apple
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: Can I use the g++ compiler with xcode? (From: Creed Erickson <email@hidden>)

  • Prev by Date: Re: Can I use the g++ compiler with xcode?
  • Next by Date: Re: Info.plist: No such file or directory
  • Previous by thread: Re: Can I use the g++ compiler with xcode?
  • Next by thread: Zero Link, C++ static initializers, Xcode 1.2
  • Index(es):
    • Date
    • Thread