Trouble using opaque pointers in Objective C++

后端 未结 1 426
暖寄归人
暖寄归人 2021-01-29 00:45

The answer to this quesion explains that opaque pointers are a good way to include C++ member variables in an Objective C++ header. I\'m getting compile errors when trying to fo

相关标签:
1条回答
  • 2021-01-29 01:32

    I don't have any problem with the following minimal sample:

    struct ADSR_opaque;
    @interface LoopyPulser : NSObject {
        struct ADSR_opaque* env;
    }
    @end
    

    If you include the header in plain Objective-C files (not Objective-C++), you have to add struct.

    Alternatively use typedefs:

    struct ADSR_opaque_;
    typedef struct ADSR_opaque_ ADSR_opaque;
    @interface LoopyPulser : NSObject {
        ADSR_opaque* env;
        // ...
    
    0 讨论(0)
提交回复
热议问题