Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Objective C++ should I import or include C++ header files

Is there anything wrong with

#import "SomeCppHeaderFile.h"

in an objective C++ header? Or should I be including like this (is there any difference if the cpp header has the usual #ifndef #define #endif header gard macros)

#include "SomeCppHeaderFile.h"
like image 653
jbat100 Avatar asked Nov 10 '11 17:11

jbat100


1 Answers

There is nothing wrong with #import "SomeCppHeaderFile.h". The #import directive does exist in the C/C++ preprocessors of GCC and Clang; the difference with #include is that it is designed to not include twice the same file in the same compilation unit.

This directive is not standard C, so if you expect to ship your libraries on other systems, be careful. As far as I know, it is supported only by GCC and Clang, and the guys at GCC don't like it much for this reason.

like image 147
zneak Avatar answered Sep 25 '22 13:09

zneak