php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39130 Compile failure when using VC++ 2005
Submitted: 2006-10-11 18:29 UTC Modified: 2012-09-21 12:40 UTC
Votes:46
Avg. Score:4.5 ± 0.9
Reproduced:39 of 41 (95.1%)
Same Version:15 (38.5%)
Same OS:35 (89.7%)
From: ben dot yan at msn dot com Assigned: pajoye (profile)
Status: Wont fix Package: Compile Failure
PHP Version: 5.2CVS-2007-07-22 OS: Windows
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-10-11 18:29 UTC] ben dot yan at msn dot com
Description:
------------
Compile with VS.NET 2005

c:\program files\microsoft visual studio 8\vc\include\sys\stat.inl(44) : error C2466: cannot allocate an array of constant size 0
c:\program files\microsoft visual studio 8\vc\include\sys\stat.inl(49) : error C2466: cannot allocate an array of constant size 0
c:\program files\microsoft visual studio 8\vc\include\sys\utime.inl(39) : error C2466: cannot allocate an array of constant size 0
c:\program files\microsoft visual studio 8\vc\include\sys\utime.inl(44) : error C2466: cannot allocate an array of constant size 0
c:\program files\microsoft visual studio 8\vc\include\sys\utime.inl(49) : error C2466: cannot allocate an array of constant size 0
c:\program files\microsoft visual studio 8\vc\include\sys\utime.inl(78) : error C2466: cannot allocate an array of constant size 0


Reproduce code:
---------------
look the zend.h :

...

#include <stdio.h>

/*
 * general definitions
 */

#ifdef ZEND_WIN32
# include "zend_config.w32.h"
# define ZEND_PATHS_SEPARATOR		';'
#elif defined(XXX)
...
#endif


Expected result:
----------------
Look the line 151 at the <../main/config.w32.h>:

/* vs.net 2005 has a 64-bit time_t.  This will likely break
 * 3rdParty libs that were built with older compilers; switch
 * back to 32-bit */
#define _USE_32BIT_TIME_T 1
#define HAVE_STDLIB_H 1


so the config.w32.h should be included first. But it isn't so in the zend.h:

#include <stdio.h>

/*
 * general definitions
 */

#ifdef ZEND_WIN32
# include "zend_config.w32.h"
# define ZEND_PATHS_SEPARATOR		';'
#elif defined(XXX)
...
#endif


This would induce the compile error. and if 

#include <stdio.h>

BEHIND the 

#ifdef ZEND_WIN32
# include "zend_config.w32.h"
# define ZEND_PATHS_SEPARATOR		';'
#elif defined(XXX)
...
#endif

,it will be ok.

Actual result:
--------------
error C2466: cannot allocate an array of constant size 0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-12 08:28 UTC] edink@php.net
Wez, you added those lines for VC++ 2005 compability. Could you have a look?
 [2006-10-12 11:19 UTC] wez@php.net
I've seen this before; I think have the fix on a company laptop that is currently occupied and I'll commit it just as soon as I can get access to it again.
 [2006-11-04 15:27 UTC] sailormax at inbox dot lv
I have same error while trying compile my module. With previous PHP all was fine.
With 5.2.0 all fine too, if comment 2 lines at config.w32.h:
#define _USE_32BIT_TIME_T 1
#define HAVE_STDLIB_H 1

used VC++ 2005 Express Edition
 [2007-04-14 04:53 UTC] dmain at themainfamily dot net
This is my output when compiling a simple dll extension using the sample source code in the online documentation.



1>------ Build started: Project: Win32_SystemCalls, Configuration: Release_TS Win32 ------
1>Compiling...
1>Source1.c
1>C:\Program Files\Microsoft Visual Studio 8\VC\include\sys/stat.inl(44) : error C2466: cannot allocate an array of constant size 0
1>C:\Program Files\Microsoft Visual Studio 8\VC\include\sys/stat.inl(49) : error C2466: cannot allocate an array of constant size 0
1>c:\projects\phpextensions\php-5.2.1\tsrm\tsrm_config_common.h(4) : fatal error C1017: invalid integer constant expression
1>Build log was saved at "file://c:\Projects\PhpExtensions\php-5.2.1\ext\Win32_SystemCalls\Release_TS\BuildLog.htm"
1>Win32_SystemCalls - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 [2007-04-14 05:00 UTC] dmain at themainfamily dot net
If I move this change, then the compiler errors are gone.  I still have another separate issue with compilation though.


This would induce the compile error. and if 

#include <stdio.h>

BEHIND the 

#ifdef ZEND_WIN32
# include "zend_config.w32.h"
# define ZEND_PATHS_SEPARATOR		';'
#elif defined(XXX)
...
#endif

,it will be ok.
 [2007-05-16 04:04 UTC] ben dot yan at msn dot com
I tried PHP5.2.2, but the problem is still there. :(
 [2007-05-19 18:24 UTC] sniper@php.net
Wez, you never got to the company laptop..? Or was it stolen? :D
 [2007-06-02 10:52 UTC] cxd at webpan dot com
Trying to compile a module for PHP 5.2.3 with VC++ 2005 SP1 I also get tons of error like:

error C2466: cannot allocate an array of constant size 0

This module (eAccelerator for Windows) compiled fine with VC++ 2005 SP1 and PHP 5.2.2.

The following might explain the cause of the problem (not sure?) that was (re)introduced with 523( again my module compiles great with PHP 522 & VC++ 2005):

----------------------------------
deprecated "default to int" rule: 

Pre-standard C++ (and all C variants predating C99), use the "default to int" rule when
declarations of functions and variables do not contain an explicit datatype. 
This behavior is maintained in Visual C++ 6.0 as the following declarations show: 


const x=0; //implicit int
static num; // implicit int
myfunc(void *ptr); //implicit return type int

In Visual Studio 2005, you have to specify the datatype explicitly:
const int x=0; static int num; int myfunc(void *ptr); 
--------------------
Hope this helps...
 [2007-06-15 12:47 UTC] grotaiche at hotmail dot com
Yeah, I have the same problem too. I recompile my extension with VS 2005 for every PHP release and I have had the problem for a while. Commenting the #define _USE_32BIT_TIME_T 1 line is not very difficult but it is a by-pass ; a more viable solution would be appreciated :)
Thanks !
 [2007-07-22 06:43 UTC] ben dot yan at msn dot com
hi,
I recompile eAccelerator v0.9.4(http://www.eaccelerator.net/) with the latest PHP(http://snaps.php.net/php5.2-latest.tar.gz), but the same problems are still there.
 [2007-07-22 15:38 UTC] jani@php.net
Wez, can you please check this out, it should be simple fix (for someone who actually has this VC++ thingie)
 [2008-02-12 02:30 UTC] someone at farpost dot com
Version 5.2.5 and VS 2005. Still have this problem.
 [2008-02-12 03:54 UTC] someone at farpost dot com
Fixed this error adding symbol _USE_32BIT_TIME_T to all projects in the Preprocessor Definitions.
 [2008-05-20 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-03-03 23:58 UTC] jmckenna at gatewaygeomatics dot com
I have the exact same problem with PHP 5.2.9 and VS 2008.

-jeff
 [2009-03-04 00:11 UTC] pajoye@php.net
We support VC6 only for 5.2.x, it may work with VS2008 (vc9) but there is no guarantee. PHP 5.3 supports 2008 out of the box.
 [2011-10-18 15:39 UTC] josephmdaly at gmail dot com
I just came across this myself with 5.3.8. If you are an extension writer with this issue, try moving php.h to the first include of your source files.
 [2012-09-21 11:11 UTC] gospodin dot p dot zh at gmail dot com
#include <iostream>
//#include "php_test_empty.h"
#include "targetver.h"
#include "php.h"

------------
>c:\program files (x86)\microsoft visual studio 9.0\vc\include\sys\stat.inl(44) 
: error C2466: невозможно выделить память для массива постоянного нулевого 
размера
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\sys\stat.inl(49) 
: error C2466: невозможно выделить память для массива постоянного нулевого 
размера
1>c:\program files (x86)\microsoft visual studio 
9.0\vc\include\sys\utime.inl(39) : error C2466: невозможно выделить память для 
массива постоянного нулевого размера
1>c:\program files (x86)\microsoft visual studio 
9.0\vc\include\sys\utime.inl(44) : error C2466: невозможно выделить память для 
массива постоянного нулевого размера
1>c:\program files (x86)\microsoft visual studio 
9.0\vc\include\sys\utime.inl(49) : error C2466: невозможно выделить память для 
массива постоянного нулевого размера
1>c:\program files (x86)\microsoft visual studio 
9.0\vc\include\sys\utime.inl(78) : error C2466: невозможно выделить память для 
массива постоянного нулевого размера

----------
means "cannot allocate an array of constant size 0"

DO SOMETHING FINALLY!!!!!!!11111oneone
 [2012-09-21 12:40 UTC] pajoye@php.net
@gospodin dot p dot zh at gmail dot com

5.2 is dead, 5.3+ only supports VC9. So no, nothing is likely to happen, sorry.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 08:01:28 2019 UTC