I am pretty new with SWIG and I can seem to figure this one out. This is sort of the base of my entire project and I am struggling here.

I am building C# wrappers for different C++ projects in the same solution.


Say I have a C++ error class defined and exported in MyModule1.lib:











   IL_BOOL IsError()const;

   IL_BOOL IsNoError()const;


   ERROR_STATUS& operator=(const ERROR_STATUS_VALUE& inStatus);

   ERROR_STATUS& operator=(const ERROR_STATUS& inStatus);


   const ERROR_STATUS_VALUE* m_pStatus;




In the same namespace, but in another project, say MyModule2.lib, I am exporting another class that contains functions returning an ERROR_STATUS.


It looks like this:


//  Class: MyClass


class DECLSPEC MyClass



   explicit MyClass(int ID);             

   virtual ~MyClass ();


   ERROR_STATUS Create (int A);



   MyClass(const MyClass & cOtherClass);

   MyClass& operator=(const MyClass & cOtherClass);




In the generated MyClass.cs, I get something like this:

  public ERROR_STATUS Create(int A) {

    ERROR_STATUS ret = new ERROR_STATUS(MyClassBridgePINVOKE.MyClass_Create__SWIG_0(swigCPtr, A), true);

    if (MyClassBridgePINVOKE.SWIGPendingException.Pending) throw MyClassBridgePINVOKE.SWIGPendingException.Retrieve();

    return ret;



Everytime I have a function that returns an ERROR_STATUS, like the Create() above, I get the same compilation error :


Error      3             'mynamespace.ERROR_STATUS.ERROR_STATUS(System.IntPtr, bool)' is inaccessible due to its protection level



Which I can clearly see in ERROR_STATUS.cs, as the function is delcared as internal:


  internal ERROR_STATUS(IntPtr cPtr, bool cMemoryOwn) {

    swigCMemOwn = cMemoryOwn;

    swigCPtr = new HandleRef(this, cPtr);





My Question is, how can I make this SWIG constructor to be generated as protected or anything else not internal so it can be used without any error?

I am sorry for the long post, thank you for your time.