Search code examples
vimcross-platformclangsizeofpowerpc

clang complete issue for cross compiled code (sizes of types are different)


I ran into an issue with the clang complete plugin in vim. The development system is Linux/i86_64, but the codebase is for PowerPC/32. The problem is that clang and the cross compiler disagree about the sizes of types. On PowerPC, sizeof long is 4, while on i86_64 it is 8.

This causes a compile-time-assert to fail that checks the size of a certain struct. As a consequence, clang complete only says -- User defined comletion (^U^N^P) and does nothing else. If I remove the compile-time-assert, everything works fine.

Is there a way to teach clang that it is not checking native code, but cross compiled code where the sizes of types are different? I.e. can I tell clang what it shall assume about the size of native types like int and long?


Solution

  • To my surprise, even the i86_64 clang supports the option

     -target powerpc
    

    for which the sizes of types have the correct type. I have added this line to my .clang_complete and it did the trick.