Making a Objective-C Wrapper for a C++ Library

后端 未结 3 503
囚心锁ツ
囚心锁ツ 2020-12-29 15:42

I am trying to make a wrapper in Objective-C so I don\'t have to write c++ outside the library classes.

The Library main file is LLAHProcessor.h .cpp

3条回答
  •  心在旅途
    2020-12-29 16:00

    In any header (.h) file in which you want to refer to LLAHProcessorWrapper, use forward class definitions instead of imports, like so:

    @class LLAHProcessorWrapper;
    @interface SomeView : UIView {
      LLAHProcessorWrapper *wrapper;
    }
    

    and make sure that the corresponding implementation file has #include LLAHProcessorWrapper.h or #import LLAHProcessorWrapper.h.

    Any implementation file in which you #include or #import your header must have .mm as its suffix if LLAHProcessorWrapper.h or anything else in the entire include tree has any C++ syntax at all. In this way, having one .mm file has a tendency to mean that huge portions of a codebase must have their files renamed to .mm.

提交回复
热议问题