Re: Streams constify API change in master leads to compilation warning for extensions
| From: | Michael Wallner | Date: | Thu, 03 Oct 2013 07:55:29 +0000 |
| Subject: | Re: Streams constify API change in master leads to compilation warning for extensions | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-69474@lists.php.net to get a copy of this message | ||
On 2 October 2013 20:41, Jakub Zelenka <bukka@php.net> wrote:
> Hi,
>
> I was wondering why stream API has been changed in this commit:
>
>
> https://github.com/php/php-src/commit/92d27ccb0574f901a107409a7fec92888fa2b82f
>
> Basically all char pointers have been constified. The thing is that this
> commit leads to compilation warning for many extensions.
>
> In my case I use php_stream_locate_url_wrapper and want to compile my
> extension (fann) without any warnings. Because this change is in master and
> not in 5.5-, I will have to add some ifdefs and cast it for 5.6+.
>
> The thing is that php_stream_locate_url_wrapper and other stream fuctions
> are often used for function parameters from zend_parse_parameters which are
> just char *. Then the values have to be casted.
>
Your claim actually makes not much sense... if you've got chat* and
you pass it to a function accepting "const char*" there should'nt be a
warning at all.
But I guess you actually declrared your variable "const char*" and get
the warning from zpp? That is not necessary:
void const_dummy(const char *data) {
printf("got %s\n", data);
}
PHP_FUNCTION(dummy)
{
char *data;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data)) {
return;
}
const_dummy(data);
}
FFI: http://en.wikipedia.org/wiki/Const#Constant_function_parameters
--
Regards,
Mike