Search Unity

IL2CPP Xcode build error "member access into incomplete type"

Discussion in 'iOS and tvOS' started by WereCrab, Aug 18, 2016.

  1. WereCrab

    WereCrab

    Joined:
    Mar 26, 2013
    Posts:
    4
    Hello

    I'm using Unity v.5.3.6, and everything was OK, until one day I added some new classes to my project, and Xcode start throwing the following errors:


    ~my_path~/Classes/Native/Bulk_Assembly-CSharp_2.cpp:177:8: note: forward declaration of 'Vector2U5BU5D_t2741383957'
    struct Vector2U5BU5D_t2741383957;
    ^
    ~my_path~/Classes/Native/Bulk_Assembly-CSharp_2.cpp:10983:213: error: member access into incomplete type 'Vector2U5BU5D_t2741383957'
    VirtActionInvoker1< Vector2_t3525329788 >::Invoke(19 /* System.Void System.Collections.Generic.List`1<UnityEngine.Vector2>::Add(!0) */, __this, (*(Vector2_t3525329788 *)(((*((Vector2U5BU5D_t2741383957**)L_0)))->GetAddressAt(static_cast<il2cpp_array_size_t>(L_1)))));
    ^
    ~my_path~/Classes/Native/Bulk_Assembly-CSharp_2.cpp:177:8: note: forward declaration of 'Vector2U5BU5D_t2741383957'
    struct Vector2U5BU5D_t2741383957;
    ^
    2 errors generated.



    I cut down my project - all assets, textures, scenes, prefabs, postprocessor scripts, etc are removed (there are only *.cs files left), but the error is still here.

    BUT When I remove any of *.cs files - error disappeared! It really looks like a black magic

    Please advise, how can I find the reason of this error to avoid it now and ever after

    ------------
    Unity ver. 5.3.6p2, Xcode ver. "7.3.1 (7D1014)
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    @WereCrab

    This is certainly a bug on the Unity side, as IL2CPP should never generated C++ code that does not compile. It may be pretty difficult for you to track down the cause of this error, unfortunately. I suspect that we will need to debug the il2cpp.exe code generation step to determine how to correct it.

    Can you submit a bug report and include the project that causes this issue? If so, please let me know the bug report number, and we'll correct this. Thanks!
     
  3. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I also have this issue and here is case number : 1302459
     
    JoshPeterson likes this.
  4. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    @JoshPeterson , Hi Josh. Were you able to take a look at the bug report I have submitted? It is preventing me from building to any platform that requires IL2CPP (All console platforms)
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Sorry, I've not looked at this bug report yet. It seems our QA team is still processing it. I'll see what I can do to move the processing forward.
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    @castor76:

    Thanks again for the bug report. I've started to investigate it now, and we're working on a fix. In the meantime, you can work around this issue.

    The problem is caused by the use of the `in` modifier on function arguments that are arrays. After I removed a few from the project in the bug report, I was able to get it to compile. I'll respond via the bug report with specifics about the changes, but I wanted to mention it here for others who might see this.

    I expect that we will be able to get this corrected in IL2CPP soon.
     
  7. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Thanks for the review. Josh.

    There is one thing that I wanted to ask.

    You have mentioned that we can remove "in" modifier but would that not cause the array to be passed by copying? ( I could be wrong ... ). If so the code behaviour may be the same, but performance wise may not. Am I correct in this?
    If it makes no difference at all, then I can just not use "in" modifier at all. Otherwise, I will bring it back once the bug has been addressed.
     
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Even without the `in` modifier, the array will be passed by reference. Some arrays are copied when passed from managed to native code via p/invoke. But for a managed to managed method call like this, the array will not be copied.
     
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    A bit of additional information on this issue - it turns out that the code also must use the `in` modifier for an array type on a virtual method to trigger this bug in IL2CPP. If the method is not virtual, the bug will not occur.
     
  10. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Good to know!