Compiling ObjC++ versus ObjC
Michael Dickens
michaelld at macports.org
Wed Jan 23 08:34:04 PST 2013
I'm working on adding a c++11 variant to qt4-mac, which requires that
all of the Qt libraries be compiled using "-std=c++11". Most of Qt
compiles without complaint, and the few files with issues are generally
easy to correct once the build errors out.
Qt4 uses a bunch of what would by current practices be called ObjC++
files (ending in .mm); I don't think any are just .m files (ObjC). I
find that /usr/bin/clang can be used to compile either .m or .mm files,
but that it treats .mm files differently; sometimes I need to use
/usr/bin/clang++ to get a particular .mm file to compile, and, really,
in my testing all of the .mm files compile more reliably using clang++
(and, without specifying anything more than the file extension; I could
always drop in a flag to tell clang to treat the file as C++ or C or
ObjC or ObjC++). I do not have any .m file to test for compiling using
clang++, so I have no idea if/how well that variant works.
So, in my limited experience, it seems to me wise to use clang (${CC})
to compile ObjC (.m) files, and clang++ (${CXX}) to compile ObjC++ (.mm)
files, with different flags (e.g., OBJCFLAGS, OBJCXXFLAGS) as well as
common ones -- just like for CFLAGS and CXXFLAGS and their respective
files (.c, .cc, .cxx, .cpp). But, I have no practical (real world)
development experience in any form of Objective C/C++. So, I ask you
MacPorts developers out there for your advice: should these files be
treated differently, or can I just use clang++ and a single set of flags
for both? Or, some other combination / variants on the above?
Thanks in advance! - MLD
More information about the macports-dev
mailing list