On 2 October 2013 20:41, Jakub Zelenka <bu...@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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to