Re: CodeGen_PECL int pass-by-reference

From: Date: Thu, 13 Sep 2007 01:15:08 +0000
Subject: Re: CodeGen_PECL int pass-by-reference
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-27915@lists.php.net to get a copy of this message
On 9/7/07, Matt Williamson <Matt.Williamson@noaa.gov> wrote: > Hello list, > > Question about CodeGen_PECL: > > I'm trying to use this to write a wrapper extension for the netCDF C > libraries > ( > http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-c/index.html#Top > ). but they have a nasty habit of returning values as pass-by-reference. So far I'm not finding > a good example of or documentation for how to do this. My attempts so far don't work, and > usually show a message like the following when compiling: > > warning: passing argument 3 of 'nc_open' from incompatible pointer type > > I'm not a C guru, which could be part of the problem, but still... > > Could somebody give me an example of what the <function> tag should look > like for, say the nc_open function? I think I can figure the rest out on > my own after that. The C prototype is: > > int nc_open (const char *path, int omode, int *ncidp); > > Its the last parameter I'm having trouble with, primarily. I need to be > able to get its value back, so I can pass it to other functions. > Are you trying to get back an int or a pointer to an int? In C passing an int by reference means passing a pointer to an int (int * var). If the function is allocating an int and returning the pointer to it for you to use then it would be an int ** var. -- Justin Patrin

« previous php.pear.general (#27915) next »