I have added one framework in my project, where to get the callbacks of framework I need to implement c++ code,for which I have added c++ classes which are .mm from .cpp
as per suggestions given in this link
I also came across few posts of StackOverflow, where I found either I have to go for C++ or Objective C source type(as suggestion of few members).
I am looking to compile c++ code along with Objective C classes,but I am getting file not found error (compile time) for #include <cstdlib> and #include <string>
Please let me know any one worked around it.or faced same Issue.
Thanks In Advance!!!
I think problem is that your's .h-file, where you have added C++ includes is included in other .m-files, not just in .mm. There is several ways to solve this problem:
Include them in
#ifdef __cplusplus
#endif
block. Also use this block for methods where C++ classes mentioned. For example:
#ifdef __cplusplus
#include <string>
using namespace std;
#endif
@interface SomeClass
#ifdef __cplusplus
- (void) setName:(const string&) name;
#endif
@end
Also there is way to avoid #ifdef #endif block by using extensions and categories:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With