# Critical typedef redefinitions

- Thread: https://externals.io/message/14261
- Original archive: https://news-web.php.net/php.internals/14261
- Started by David Strauss on 2005-01-02T10:41:32+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #14261 — David Strauss — 2005-01-02T10:41:32+00:00

URL: https://externals.io/message/14261#14261

Hi!

There is a small problem in cgi_main.c preventing it to be compiled  
properly
with some compilers.

WS2tcpip.h will get included into cgi_main.c by following inclusion chain:
cgi_main.c <- php_standard.h <- fsock.h <- php_network.h <- WS2tcpip.h

Since php.h is included several lines before, socklen_t is already defined  
as:
php.h (151): typedef unsigned int socklen_t;

Now WS2tcpip.h gets included and tries to redefine socklen_t as:
WS2tcpip.h (593): typedef int socklen_t;

I successfully tested it with the VectorC compiler, where this lead to a
terminal error.

- David


Addendum:
If you take a look into the CVS snapshot build log, you'll probably see  
this
warning quite a lot of times (58x according to my editor):
C:\\Program Files\\Microsoft SDK\\Include\\.\ws2tcpip.h(593) : warning  
C4142: benign redefinition of type

Since this occurs throughout the whole build, the easiest solution is  
proabably
to just change the lines 150-152 in php.h to something like this:

#ifndef HAVE_SOCKLEN_T
# ifdef PHP_WIN32
     typedef int socklen_t;
# else
     typedef unsigned int socklen_t;
# endif
#endif

---

## #14263 — Wez Furlong — 2005-01-02T16:29:46+00:00

URL: https://externals.io/message/14261#14263 · In reply to: #14261

We only support the MSVC compiler and libc under windows (there are
plenty of quirks and assumptions made about it for the win32 build).

Changing that typedef is slightly tricky; I left it as it was because
there were compilation problems using older versons of MSVC and the
platform SDK, and this redefinition is benign.

If you can test you proposed change with MSVC 6, VS.Net and your
VectorC compiler and make sure that it all still works, then we can
commit it.

--Wez.


> Hi!
> 
> There is a small problem in cgi_main.c preventing it to be compiled
> properly
> with some compilers.
> 
> WS2tcpip.h will get included into cgi_main.c by following inclusion chain:
> cgi_main.c <- php_standard.h <- fsock.h <- php_network.h <- WS2tcpip.h
> 
> Since php.h is included several lines before, socklen_t is already defined
> as:
> php.h (151): typedef unsigned int socklen_t;
> 
> Now WS2tcpip.h gets included and tries to redefine socklen_t as:
> WS2tcpip.h (593): typedef int socklen_t;
> 
> I successfully tested it with the VectorC compiler, where this lead to a
> terminal error.
> 
> - David
> 
> Addendum:
> If you take a look into the CVS snapshot build log, you'll probably see
> this
> warning quite a lot of times (58x according to my editor):
> C:\\Program Files\\Microsoft SDK\\Include\\.\ws2tcpip.h(593) : warning
> C4142: benign redefinition of type
> 
> Since this occurs throughout the whole build, the easiest solution is
> proabably
> to just change the lines 150-152 in php.h to something like this:
> 
> #ifndef HAVE_SOCKLEN_T
> # ifdef PHP_WIN32
>      typedef int socklen_t;
> # else
>      typedef unsigned int socklen_t;
> # endif
> #endif
