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

Re: libssh and Visual C++ (again)


2012/9/30 Aris Adamantiadis <aris@xxxxxxxxxxxx>

>
> > Replacing ssize_t by int32_t is an ABI breakage under 64 bits platforms
> > Replacing ssize_t by int64_t is an ABI breakage under 32 bits platforms
> >
> > The definition of ssize_t is : the same bit count as size_t, but signed.
> >
> > Christophe
> >
>
> Hi,
>
> I did not follow the whole thread, but based on your description, why not:
> #if (sizeof(size_t)==4)
> typedef u_int32_t ssh_ssize_t
> #else
> typedef u_int64_t ssh_ssize_t
> #endif
>
> I also wonder if ssize_t is the appropriate type for the return of such
> functions. The libc use int for read(2) for a reason.
> When did we introduce them in libssh ? if it's a recent patch we could
> simply go back to an int.
>
> Aris
>
> Hi Aris
Sadly, in C, typedefs are parsed *after* preprocessor #if directives. This
means that it it not possible to probe types in #if / #else / #endif
directives (your code don't work as expected)
One way is to use a "two pass" process. The first pass is done by automake
or cmake, to build an intermediate include file (config.h for example)
The preprocessor does the second pass, using the generated include file

This two pass process is heavy, and might not be the best solution.

Archive administrator: postmaster@lists.cynapses.org