【问题标题】:Compilation error when compiling php extension编译php扩展时出现编译错误
【发布时间】:2011-11-07 21:45:01
【问题描述】:

我正在关注 this tutorial 为 php 构建一个 hello-world 类型扩展,并在 Windows7 上使用 Visual Studio 2008 Express 进行编译。构建时,出现以下错误:

  • 1 与分配大小为 0 的常量数组有关
  • 其他的似乎与时间有关。

但我不确定它们的全部含义或如何解决它们。

Compiling...
stdafx.cpp
C:\Program\VS2008\VC\include\sys/stat.inl(44) : error C2466: cannot allocate an array of constant size 0
C:\Program\VS2008\VC\include\sys/stat.inl(49) : error C2466: cannot allocate an array of constant size 0
C:\Program\VS2008\VC\include\sys/utime.inl(39) : error C2466: cannot allocate an array of constant size 0
C:\Program\VS2008\VC\include\sys/utime.inl(44) : error C2466: cannot allocate an array of constant size 0
C:\Program\VS2008\VC\include\sys/utime.inl(49) : error C2466: cannot allocate an array of constant size 0
C:\Program\VS2008\VC\include\sys/utime.inl(78) : error C2466: cannot allocate an array of constant size 0
C:\Program\VS2008\VC\include\wtime.inl(37) : error C2664: '_wctime32' : cannot convert parameter 1 from 'const time_t *' to 'const __time32_t *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Program\VS2008\VC\include\wtime.inl(43) : error C2664: 'errno_t _wctime32_s(wchar_t *,size_t,const __time32_t *)' : cannot convert parameter 3 from 'const time_t *' to 'const __time32_t *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Program\VS2008\VC\include\time.inl(32) : warning C4244: 'argument' : conversion from 'time_t' to '__time32_t', possible loss of data
C:\Program\VS2008\VC\include\time.inl(32) : warning C4244: 'argument' : conversion from 'time_t' to '__time32_t', possible loss of data
C:\Program\VS2008\VC\include\time.inl(38) : error C2664: '_ctime32' : cannot convert parameter 1 from 'const time_t *' to 'const __time32_t *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Program\VS2008\VC\include\time.inl(44) : error C2664: 'errno_t _ctime32_s(char *,size_t,const __time32_t *)' : cannot convert parameter 3 from 'const time_t *' to 'const __time32_t *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Program\VS2008\VC\include\time.inl(51) : error C2664: '_gmtime32' : cannot convert parameter 1 from 'const time_t *' to 'const __time32_t *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Program\VS2008\VC\include\time.inl(57) : error C2664: '_gmtime32_s' : cannot convert parameter 2 from 'const time_t *' to 'const __time32_t *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Program\VS2008\VC\include\time.inl(64) : error C2664: '_localtime32' : cannot convert parameter 1 from 'const time_t *' to 'const __time32_t *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Program\VS2008\VC\include\time.inl(69) : error C2664: '_localtime32_s' : cannot convert parameter 2 from 'const time_t *' to 'const __time32_t *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Program\VS2008\VC\include\time.inl(81) : error C2664: '_time32' : cannot convert parameter 1 from 'time_t *' to '__time32_t *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

【问题讨论】:

    标签: php c visual-studio-2008 compilation php-extension


    【解决方案1】:

    如果您查看文件中的那些行,那么在 STATIC_ASSERT 的定义中,这些实际上是 STATIC_ASSERT 失败,检查标准类型名称是否与特定于大小的 32 位类型名称匹配。在我看来,您在 32 位和 64 位编译之间存在某种不匹配。

    无法分配大小为 0 的数组的业务是静态断言宏中使用的技巧。信息量不大。

    【讨论】:

      猜你喜欢
      • 2012-10-11
      • 2023-04-11
      • 2014-11-23
      • 1970-01-01
      • 1970-01-01
      • 2020-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多