#1368 ASCII values represented as 'char' in enums are incorrectly translated to C#


SWIG 3.0.0 fails to wrap pjsip 2.2.1 with C# code correctly. Everything, as far as I can see, but the files format.h and event,h in the pjmedia project are converted correctly. format.h and event.h contain two enums, pjmedia_format_id and pjmedia_event_type which both get their enum values set using macros.

As an example the field PJMEDIA_FORMAT_PCMA in pjmedia_format_id is set to "PJMEDIA_FORMAT_PACK('A', 'L', 'A', 'W')" which is preprocessed down to "( 'W'<<24 | 'A'<<16 | 'L'<<8 | 'A' )". The resulting C# code as output by swig using -csharp and -c++ as arguments is "PJMEDIA_FORMAT_PCMA = (((W << 24)|(A << 16))|(L << 8))|A". The correct output should have been something like "PJMEDIA_FORMAT_PCMA = ((((int)'W' << 24)|((int)'A' << 16))|((int)'L' << 8))|(int)A".

I've attached format.h, event.h as well as pjmedia_format_id.cs.

3 Attachments


  • Olly Betts

    Olly Betts - 2016-09-12
    • status: open --> closed-duplicate
    • Group: -->
  • Olly Betts

    Olly Betts - 2016-09-12

    Also reported at https://github.com/swig/swig/pull/781 - we're using the github tracker in preference to this one, and that has a patch, so closing this issue as a duplicate.


Log in to post a comment.