PHP7和Apache编译警告

3

当我构建php 7.0.1时,出现了一些警告,希望在新版本中能得到修复,但今天在7.0.2中又出现了更多的警告。

PHP

php_date.c文件生成了6个警告。

/Users/username/folder/php/ext/date/php_date.c:2196:6: warning: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value] abs(utc_offset / 60),
                                                ^
/Users/username/folder/php/ext/date/php_date.c:2196:6: note: use function 'llabs' instead abs(utc_offset / 60), ^~~ llabs
          6 warnings generated.

interval.c生成的1个警告

/Users/javidgajievi/Ovlee/php/ext/date/lib/interval.c:73:13: warning: using integer absolute value function 'abs' when argument is of
      floating point type [-Wabsolute-value]
        rt->days = abs(floor((one->sse - two->sse - (dst_h_corr * 3600) - (dst_m_corr * 60)) / 86400));
                   ^
/Users/javidgajievi/Ovlee/php/ext/date/lib/interval.c:73:13: note: use function 'fabs' instead
        rt->days = abs(floor((one->sse - two->sse - (dst_h_corr * 3600) - (dst_m_corr * 60)) / 86400));
                   ^~~
                   fabs
1 warning generated.

并且pthreads生成了一个警告

ext/pthreads/src/object.h:41:1: warning: '/*' within block comment [-Wcomment]
/* {{{ */
^

Apache

Apache产生了更多的警告信息,我将列出其中一些以便您了解这些警告。

mod_authnz_ldap.c:554:50: warning: 'ldap_err2string' is deprecated: first deprecated in OS X 10.11 - use OpenDirectory Framework
      [-Wdeprecated-declarations]
                      user, r->uri, ldc->reason, ldap_err2string(result));
                                                 ^
/Users/username/folder/apache/include/http_log.h:448:44: note: expanded from macro 'ap_log_rerror'
#define ap_log_rerror(...) ap_log_rerror__(__VA_ARGS__)
                                           ^
/Users/username/ovlee/apache/include/http_log.h:451:63: note: expanded from macro 'ap_log_rerror__'
             ap_log_rerror_(file, line, mi, level, status, r, __VA_ARGS__); \

我的构建配置

PHP

./configure \
--prefix=/Users/username/fodler/php \
--exec-prefix=/Users/username/folder/php \
--with-apxs2=/Users/username/folder/apache/bin/apxs \
--with-config-file-scan-dir=/Users/username/folder/php/lib \
--with-config-file-path=/Users/username/folder/php/lib \
--disable-all \
--enable-maintainer-zts \
--enable-pthreads

Apache

./configure \
--prefix=/Users/username/fodler/apache \
--exec-prefix=/Users/username/folder/apache \
--with-pcre=/Users/username/folder/apache/pcre \
--enable-module=so \
--with-mpm=worker

因为我认为问题可能是由我的环境引起的,所以我不会列出所有警告。我的环境是Mac OSX 10.11.2,xCode 7.2,PHP 7.0.2,APAHCE(Httpd) 2.4.18。

你认为问题是什么?我该如何修复这些警告?


1
还有其他问题吗? - Sami Kuhmonen
显然问题是,我该如何修复这些警告? - user4672604
您想修改/修复代码(并可能向php源代码库做出贡献)吗? - VolkerK
我只想知道这些警告的原因。 - user4672604
1个回答

1

"我只想知道这些警告的原因。"
好的,不确定这是否真的会帮助你,但我们可以试试... ;-)

关于/Users/username/folder/php/ext/date/php_date.c:2196:6:
这一行代码是

abs(utc_offset / 60)

其中utc_offset被声明为timelib_sll utc_offset
timelib_sll被定义为

#if defined(_MSC_VER)
typedef uint64_t timelib_ull;
typedef int64_t timelib_sll;
# define TIMELIB_LL_CONST(n) n ## i64
#else
typedef unsigned long long timelib_ull;
typedef signed long long timelib_sll;
# define TIMELIB_LL_CONST(n) n ## ll
#endif

在timelib_structs.h中,由于你使用的是mac,_MSC_VER未被定义,因此timelib_sll是一个short long long。
编译器会抱怨一个short long long*被传递给了一个期望int的函数(在你的情况下比long long“小”得多)。
类似的问题也出现在interval.c:73的警告中。
我从php.net下载的存档中没有包含ext/pthreads目录,但警告信息表明有人放置了像这样的注释。
/**
lalala
  /* {{{ */
*/

在那个文件中,编译器抱怨嵌套的注释块。

关于 mod_authnz_ldap.c:554:50: warning: 'ldap_err2string' is deprecated: 苹果公司希望开发人员现在使用另一个函数。现在我不知道替换是什么。
以下两条消息(包含expanded from macro的消息)只是暗示了源代码的位置;由于它在宏扩展中,否则可能很难找到它。 (由于这看起来明显像 CLANG 警告,所以我查了一下,是的:从 Xcode 4.2 开始,Clang 是 Mac OS X 的默认编译器。 - 所以我从中学到了一些东西;-))


“编辑和顺便说一句:
下一行是”
abs((utc_offset % 60)))

我没有收到警告,因为编译器足够聪明,能够识别模60的结果在int值范围内。


谢谢您花时间理解这个过程,但我真正感兴趣的是这些警告的原因,我指的是这些警告是由于错误还是由于我的机器造成的。不过,这个答案值得一票。 - user4672604
虽然可能,但在这种情况下与您的机器、配置或设置无关。而您发布的那些内容目前似乎并不重要。 - VolkerK
是的,尽管有警告,PHP和Apache都正常工作,我只是认为我应该关注构建过程的每个细节。再次感谢。 - user4672604

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接