deuill / go-php

PHP bindings for the Go programming language (Golang)
MIT License
925 stars 105 forks source link

Fix "warning: initialization from incompatible pointer type" #58

Closed thekid closed 5 years ago

thekid commented 5 years ago

This pull request fixes the following error:

engine.c:97:2: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
  engine_log_message,          // Log Message
  ^~~~~~~~~~~~~~~~~~
engine.c:97:2: note: (near initialization for ‘engine_module.log_message’)

The extra parameter syslog_type_int was introduced in PHP 7.1, see this commit.

thekid commented 5 years ago

For PHP < 7.1.0, this is necessary:

diff --git a/engine.c b/engine.c
index d3a7ead..4c87203 100644
--- a/engine.c
+++ b/engine.c
@@ -63,7 +63,11 @@ static void engine_register_variables(zval *track_vars_array) {
        php_import_environment_variables(track_vars_array);
 }

+#if PHP_VERSION_ID < 70100
+static void engine_log_message(char *str) {
+#else
 static void engine_log_message(char *str, int syslog_type_int) {
+#endif
        engine_context *context = SG(server_context);

        engineWriteLog(context, (void *) str, strlen(str));
deuill commented 5 years ago

Thanks! I might drop PHP 5.x support at some point and have more granular tags, but until then we'll need to use constants like so.

austgl commented 4 years ago

It's time to drop support for PHP 5.x.