This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: A makefile with a mix of gcc and g++
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Mahmood Naderan <nt_mahmood at yahoo dot com>
- Cc: gcc <gcc-help at gcc dot gnu dot org>
- Date: Tue, 12 Apr 2011 12:10:20 +0100
- Subject: Re: A makefile with a mix of gcc and g++
- References: <396295.96394.qm@web111702.mail.gq1.yahoo.com>
On 12 April 2011 11:57, Mahmood Naderan wrote:
> Hi,
> I have a makefile that compiles source files with gcc. However I want to exclude
> one file and compile it with g++ (since I want to use STL in a pure ANSI C
> application).
If your application is *pure* C then you can't use C++, so I'm not
sure what you mean.
> The question is how can I do that in such a way that make file
> automatically compile this file with g++ and others with gcc.
This is a question about writing makefiles, which is not a question
about using gcc, however ...
The answer entirely depends how your makefile is written. The
conventional way would be for C files to be compiled with $(CC) and
C++ files to be compiled with $(CXX) so you would simply ensure that
your source files have the correct file extensions so make correctly
identifies their type and uses the correct rule for compiling that
file type.
So just use the conventional file extension for C++, one of .cc, .C, .cpp etc.