Thanks. This must be an Apple compiler-specific thing. It is widely used in Mac/iOS headers.
which gets translated into a 4-byte integer fine with llvm but SWIG just doesn't know it. 
I wonder if it's necessary to write a typemap to do a conversion from that 
data to a plain integer, which sounds quite inefficient. Otherwise, I'd have to ignore all those prototypes 
in the binding generation, but still have to ignore thousands of Apple library headers to avoid compiling 
them in the C wrapper, which is practically impossible.

Are there any other ways out?


On 2013-09-18, at 9:15 PM, Bo Schwarzstein <> wrote:

I never see such a grammar for enum type in C++. In C++, enum is just a int number, so your code made it as a string must be wrong. And also I don't think you can assign a string to enum type in C#, maybe you have to create some static const global string from C++ as your enum type.

2013/9/19 Beinan Li <>

I'm generating C# binding for C/C++ code.
enum usually works fine, but with Apple's 4-char enum, 
the 4-char enums get directly used on the C# side 

The C++ prototype:

enum AudioSessionCategory
kAudioSessionCategory_AmbientSound               = 'ambi',
kAudioSessionCategory_SoloAmbientSound           = 'solo',
kAudioSessionCategory_PlayAndRecord              = 'plar'

I got translated C# enum

public enum AudioSessionCategory {
  kAudioSessionCategory_AmbientSound = 'ambi',
  kAudioSessionCategory_SoloAmbientSound = 'solo',
  kAudioSessionCategory_PlayAndRecord = 'plar'

and cause compiler errors:

    error CS1012: Too many characters in character literal

Should I write a typemap for these enums and how?


LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13.
Swig-user mailing list