This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A makefile with a mix of gcc and g++


>The conventional way would be for C files to be compiled with $(CC) and
> C++ files to be compiled with $(CXX)

>you can add a specific rule, like:
>special_file.o: special_file.c
>g++ <foo bar>

Thanks, I got it.

>If your application is *pure* C then you can't use C++, so I'm not
>sure what you mean.

I meant that in a pure?.c, I want to?use STL. For example "#include <vector>" 
and use it. 


Anyway?thanks for your suggestion.
?
// Naderan *Mahmood;



----- Original Message ----
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Mahmood Naderan <nt_mahmood@yahoo.com>
Cc: gcc <gcc-help@gcc.gnu.org>
Sent: Tue, April 12, 2011 3:40:20 PM
Subject: Re: A makefile with a mix of gcc and g++

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]