By changing 

 project_OBJC_FILES = main.m

to 

 project_OBJCC_FILES = main.mm

and install GNU Objective-C++ compiler fix my problem. 

Applogize for not being able to expressing my question precisely. 

Thanks for patentinetly helping fix my problem. 

----- Original Message -----
From: David Chisnall
Sent: 09/15/13 11:00 PM
To: Hungwin Chen
Subject: Re: enable c++

You appear to be asking the wrong question. The question that you want to ask 
is 'how do I specify C++ or Objective-C++ files in a GNUstep Make GNUmakefile?' 
The useful information that you could have provided up until this point was how 
you are specifying the files currently. The answer to the question that you 
mean is to use project_OBJCC_FILES= instead of project_OBJC_FILES (where 
project is the name of your project). David On 15 Sep 2013, at 15:14, "Hungwin 
Chen" <[email protected]> wrote: > The project is organized as following 
structure > > project_root/a/b/{GNUmakefile, main.m, *.pch, ...} > 
project_root/library/x/{*.h, *.cpp, *.mm, ...} > > In the pch file,preprocessor 
directive > > #ifdef __cplusplus > ... > #endif > > is added so that the 
command `make` would compile that source (with other cpp files not recognized). 
With this scenario, all cpp related files need preprocessor directive added, 
which looks not a good way to compile a c++ project.So I am learning how to 
enable c++ so that the project can be compiled without error messages being 
thrown. > > I tried moving .m file to .mm by e.g. renaming main.m to main.mm 
but `make' complains the following error > > No rule to make target 
`obj/Project.obj/main.mm', needed by `Project.app/./Project'. Stop. > > If 
using main.m make would compile with other c++ sources in library folder not 
recognized (if no preprocessor directive is added). For instance, > > error: 
unknown type name ‘class’ > > where in the library folder a header file 
contains following code > > class A;// <-- error message complains this class 
is unkown > @protocol AFactory; > @interface AView : NSOpenGLView > > 
Therefore, I would like to learn how to enable c++ for the entire project, 
instead of using preprocessor directive. > > Thanks > > > > > >> ----- Original 
Message ----- >> From: David Chisnall >> Sent: 09/15/13 08:09 PM >> To: Hungwin 
Chen >> Subject: Re: enable c++ >> >> On 15 Sep 2013, at 13:00, "Hungwin Chen" 
<[email protected]> wrote: >> >> > At the moment my project compilation is 
done through preprocessor directive, e.g. >> >> This sentence doesn't make any 
sense, so it would help if you could explain what you mean by it. >> >> > 
#ifdef __cplusplus >> > ... >> > #endif >> > >> > However, most of code are 
c++, passing command `make CC=/usr/bin/g++` dosn't enable gnustep recgonize c++ 
program. So what parameter should I pass so that the compilation can recognize 
c++ program? >> >> This will tell it to compile C code with g++, which is 
almost certainly not what you want. It will use CXX (which hopefully is 
clang++, but might be g++) for any [Objective-]C++ code. This is identified by 
the .cc, .C, or .cpp extension for C++ or .mm for Objective-C++. >> >> David >> 
>> -- Sent from my Apple II >> > -- Sent from my Difference Engine
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to