From: William S F. <ws...@fu...> - 2009-02-06 19:11:47
|
Without a standalone testcase and compiler options etc, it is hard to tell, but I've never seen gcc have problems with the generated code from a simple constructor type %extend. William Rich E wrote: > This works very elegantly! > > One thing, I get a warning during compilation that the following > function is not a prototype: > > SWIGINTERN SMS_AnalParams *new_SMS_AnalParams(){ > SMS_AnalParams *s = (SMS_AnalParams *)malloc(sizeof(SMS_AnalParams)); > sms_initAnalParams(s); > return s; > } > > It works, so does anyone know why gcc is complaining? > > > thanks for the help, cheers.. > > rich > > On Wed, Feb 4, 2009 at 11:17 PM, William S Fulton > <ws...@fu...> wrote: >> Rich E wrote: >>> Anyone know of a good example on how to do this? Basically, in my C >>> code, I have a function that initializes a structure to default >>> values. So, in python I need to do something like: >>> >>>>> analParams = SMS_AnalParams() >>>>> sms_initAnalParams(analParams) >>> I'm sure it is possible to make the second step happen automatically, >>> but the various stabs I just took at it didn't work. Anyone that has >>> done this or knows how, would you mind giving a recommendation? >>> >> Use constructor syntax in a %extend block, something like: >> >> %extend SMS_AnalParam { >> SMS_AnalParam() { >> SMS_AnalParam *s = (SMS_AnalParam *)malloc(sizeof(SMS_AnalParam)); >> sms_initAnalParams(s); >> return s; >> } >> } >> >> It works for C code. >> >> William >> > |