Re: Warning about passing argumensts by reference
| From: | Manuel Lemos | Date: | Tue, 25 Nov 2003 16:30:56 +0000 |
| Subject: | Re: Warning about passing argumensts by reference | ||
| References: | 1 2 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-231@lists.php.net to get a copy of this message | ||
Hello,
On 11/24/2003 02:29 PM, Sara Golemon wrote:
Ah, I thought there was something missing in functions like flock that have an argument to be passed by reference but they do not declare it as such. Does that apply also to when the arguement to be passed by reference is optional? If so, am I right to assume that the function entry for flock in ext/standard/basic_functions.c is incorrect? PHP_FE(flock, NULL) The prototype of flock in ext/standard/file.c is: /* {{{ proto bool flock(resource fp, int operation [, int &wouldblock]) Another question, given that the argument is passed by reference, according to this Zend API documentation page, shouldn't functions be using calls like zend_get_parameters() and convert_to_long() instead of zend_get_parameters_ex() and convert_to_long_ex() to write to parameters passed by reference? http://www.zend.com/apidoc/zend.arguments.by-reference.php I have been problems using flock with the wouldblock optional parameter. I think the problem is that the wouldblock argument is not being declared and accessed properly. If I am correct, this needs to be fixed. I just do not have enough information to be certain and file a bug report and maybe submit a patch. Can anybody comment on this? -- Regards, Manuel Lemos Free ready to use OOP components written in PHP http://www.phpclasses.org/The problem is that odbtp_attach_field() is a PECL function and not a script declared function. What do I need to do in the C code declaration of this function to prevent this warning from occuring? Below is the code for this function.Make a structure in the same file where your PHP_FE(odbtp_attach_field, NULL) declaration is: staticZEND_BEGIN_ARG_INFO(third_arg_force_ref, 0) ZEND_ARG_PASS_INFO(0) ZEND_ARG_PASS_INFO(0) ZEND_ARG_PASS_INFO(1) ZEND_END_ARG_INFO()Then change your FE declaration to: PHP_FE(odbtp_attach_field, third_arg_force_ref) Then in your script simply don't bother trying to pass your argument by reference, the function handler will know how to deal with it.