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
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep