[FFmpeg-devel] [PATCH] socklen_t definition

Michael Niedermayer michaelni
Tue Sep 18 12:56:07 CEST 2007


Hi

On Tue, Sep 18, 2007 at 12:30:37PM +0200, Diego Biurrun wrote:
> On Mon, Sep 17, 2007 at 04:41:34PM -0700, Dave Yeo wrote:
> > Reimar Doeffinger wrote:
> > > On Mon, Sep 17, 2007 at 12:35:46PM +0200, Diego Biurrun wrote:
> > >> Even more important: Reimar came up with a header file that provides the
> > >> correct definition.  So why can't this be used instead of adding this
> > >> (possibly brittle as explained by Mans) check?
> > > 
> > > I'm not sure that is a proper header file, at least it's not a system
> > > one...
> > > But it seems that _socklen_t is in some header file, maybe using that is
> > > good enough?
> > 
> > Grepping include I found in <386/ansi.h>
> > /*
> >   * Types which are fundamental to the implementation and must be declared
> >   * in more than one standard header are defined here.  Standard headers
> >   * then use:
> >   *      #ifdef  _BSD_SIZE_T_
> >   *      typedef _BSD_SIZE_T_    size_t;
> >   *      #undef  _BSD_SIZE_T_
> >   *      #endif
> >   */
> > ...
> > #define _BSD_SOCKLEN_T_ __uint32_t              /* socklen_t (duh) */
> > ...
> > 
> > And in <sys/_type.h>
> > ...
> > typedef __uint32_t      __socklen_t;
> > ...
> > So it seems that it should be uint32_t. Also __uint32_t is typedef as
> > unsigned int in <386/_types.h>.
> 
> I get to repeat my question: Is there a way to include this header file
> instead of adding the check from the patch?

btw, an alternative solution to find the type of something is to compile
code like:
-----------
#include <inttypes.h>
#include <sys/socket.h>

int (*ptr)(int SOCKET, struct sockaddr *ADDR, TYPE *LENGTHPTR);

void test(void){
    TYPE c;
    getsockname(0, NULL, &c);
    ptr= getsockname;
}
------------

with -W -Wall and all types beginning from the most likely and when it
prints no warnings then we got the correct type

this of corse depends on the compiler printing warnings if types missmatch

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070918/75307096/attachment.pgp>



More information about the ffmpeg-devel mailing list