tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Few files are missing for socket programming on Windo


From: Christian Jullien
Subject: Re: [Tinycc-devel] Few files are missing for socket programming on Windows
Date: Mon, 8 Apr 2019 19:50:51 +0200

Hi Michael,

When you do socket programming on unix, you have to include ~10 different 
headers that provide all function and constant declarations (socket, bind, 
select, ntohl ...) needed by BSD socket programming. Exact includes list 
depends on unix system (solaris, BSD, Linux, macOS, AIX, HP UX ...)
On Windows, this set is different. Basically, winsock2.h provides them all (but 
using internally qos.h and ws2ipdef.h by transitive closure).

A Windows programmer, as I do, just uses:
#include <winsock2.h>

So a "portable code" looks like

#if defined(_WIN32)
#include <winsock2.h>
#else
// assume unix like ask ./configure which ones exist on specific system....
#if defined(HAVE_SYS_IOCTL_H)
#include <sys/ioctl.h>
#endif
#if defined(HAVE_SYS_SOCKET_H)
#include <sys/socket.h>
#endif
#if defined(HAVE_NETINET_IN_H)
#include <netinet/in.h>
#endif
#if defined(HAVE_NETINET_TCP_H)
#include <netinet/tcp.h>
#endif
#if defined(HAVE_ARPA_INET_H)
#include <arpa/inet.h>
#endif
#if defined(HAVE_NETDB_H)
#include <netdb.h>
#endif
... // And others
#endif

I'm reluctant  to edit those 3 Windows headers as using them ROOTB make socket 
programming work on Windows. I may grab newer versions from future 
win-api-full...

My goal to let tcc user download tcc standard distrib and make their "portable" 
code working whether they are on Windows or on Linux.
Those wanting to do GUI or Windows specific code, will need to download the 
winapi-full-for-0.9.27 archive.

Hope it's more clear. Waiting from grischka input...

C.


-----Original Message-----
From: Michael Matz [mailto:address@hidden 
Sent: Monday, April 08, 2019 19:24
To: address@hidden; address@hidden
Subject: Re: [Tinycc-devel] Few files are missing for socket programming on 
Windows

Hi,

On Sun, 7 Apr 2019, Christian Jullien wrote:

> Programming with sockets on Windows require:
> - qos.h 
> - winsock2.h
> - ws2ipdef.h

Are qos.h and ws2ipdef.h really headers normally included by user code
or are they included in winsock2.h for some arcane features?  (I have no 
idea about Windows socket programming, so genuine question).  If the 
latter you might do like grischka and comment out some more arcane 
includes of winsock2.h and then would only need to add this one header and 
the .def file.

> And
> - ws2_32.def
> 
> Which are missing from standard tinycc git repository (under win32).
> 
> Ok I've grabbed .h from winapi-full-for-0.9.27 and "./tcc -impdef 
> $(WINDIR)/System32/ws2_32.dll -o lib/ws2_32.def" produced missing .def
> 
> Question, do you allow me to add those files in win32 repository subdir?
> 
> Rationale:
> - socket is an important part of software programming
> - socket is not Windows specific and can be used to make programs compatible 
> between linux and Windows

So the winsock2.h API is roughly equivalent to the POSIX socket API?  
Otherwise this argument is less convincing.

> - ws2_32.def is missing from winapi-full-for-0.9.27
> - winapi-full-for-0.9.27 is BIG as it contains almost all Windows API, so it 
> only useful for those doing Windows specific programming and they'll probably 
> use them all.
> 
> Is it OK for those 4 additional files?

I think it's reasonable to add (but as said above, maybe you can make it 
two files only), but we do need to be careful about feature-creep; 
winapi-full exists for a reason, so we should continue to have tinycc only 
provide basic headers from the target system.  (I would personally go even 
further and remove even the windows specific headers that we have, but I 
do realize that that might be a bit harsh to users that simply want to 
checkout tinycc and see it working).

I would like to know what grischka has to say to this, though, so give it 
a couple days before you include them.


Ciao,
Michael.

> Btw, I also modified my https://sourceforge.net/projects/wintcc/ which 
> makes standalone and reproducible tcc 32/64 Windows executables 
> bootstrapped with Cygwin. So I'm personally not lost with socket on 
> Windows.
> 
> Christian
> 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]