Re: csconstvalue seems unusable
William S Fulton <[email protected]>
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CANGqftBuQyntMEF=upaS9nVMf1TW_Gyky0QQoW=2catO+ZV_4A@mail.gmail.com> |
On Tue, 4 Feb 2020 at 18:24, Shawn Laptiste <[email protected]> wrote: > I'm in the process of revising the swig file that, in conjunction with > some python scripts, takes care of transforming our C/C++ API into a C# API > for our Unity users. Our API has a number of constants that are being > specified using code similar to the following: > %constant IntegerType InvalidId = unchecked((ulong)(-1)); > I have spent some time investigating %csconst and %csconstvalue, and I > believe %csconstvalue is what I need, but I can't figure out why it keeps > failing with the following console error: > MyDrive:\ObscuredFolders\SwigFile.swig(11) : Error: Syntax error in > input(1). > > The following works for me: %inline %{ typedef unsigned long long IntegerType; %} %{ unsigned long long unchecked(unsigned long long i) { return i; } %} %csconstvalue("unchecked((ulong)(-1))") InvalidId; %constant IntegerType InvalidId = unchecked((ulong)(-1)); And generates C# code: public static readonly ulong InvalidId = unchecked((ulong)(-1)); I'm not sure why you have an 'unchecked' call in your %constant as then you need a C++ function called unchecked. If you are getting syntax errors, provide the exact input (with all macros expanded) for further help. William _______________________________________________ Swig-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/swig-user