|
Re: bug while wrapping const char arrays without an explicitly defined size: msg#00191programming.swig
Marcelo Matus writes: > > > And that is the way the 'char *' datatype is working, nothing has been > changed, > that is what we call "strings", ie, the one that always have a NULL ending > character. > > The thing is that 'char*' and 'char[ANY]' are different, in C you can > always get > sizeof(char[ANY]) -> ANY, you don't need to use strlen because the size > is known, C doesn't require the char[ANY] to be NULL-terminated, etc. No, but it usually is NULL-terminated anyways. If I have: char pathname[256] = "/whatever"; I don't expect to get a 256 character string back when I read it. > But I will add the code to delete the ending NULL chars by default, so, > char *, char[ANY] and char[] will look more alike. My personal preference on this is that all strings involving char (regardless of pointer, array, etc) default to NULL-terminated. As a special case, char arrays with no dimensions [] should additionally be readonly. On the other hand, if we had some documented built-in typemaps that could be used to handle the other cases, that would be good. > Should we also need to add something to the docs saying that > the same rules for the char * datatype will apply to char[ANY] > and char[]? Sure. Cheers, Dave _______________________________________________ Swig maillist - Swig@xxxxxxxxxxxxxxx http://mailman.cs.uchicago.edu/mailman/listinfo/swig |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: bug while wrapping const char arrays without an explicitly defined size: 00191, Marcelo Matus |
|---|---|
| Next by Date: | derived types: 00191, David E. Konerding DSD Staff |
| Previous by Thread: | Re: bug while wrapping const char arrays without an explicitly defined sizei: 00191, Marcelo Matus |
| Next by Thread: | SWIG_ConvertPtrFromString bug in SWIG 1.3.20 & 1.3.21: 00191, Abhinandan Jain |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |