develooper Front page | perl.perl5.porters | Postings from September 2003

Re: Interesting - [drow@mvista.com: A user's experiences with GCC-3.4 snapshots]

Thread Previous | Thread Next
From:
Andy Dougherty
Date:
September 17, 2003 17:27
Subject:
Re: Interesting - [drow@mvista.com: A user's experiences with GCC-3.4 snapshots]
Message ID:
Pine.SOL.4.53.0309172024490.2200@maxwell.phys.lafayette.edu
On Tue, 16 Sep 2003, Chip Salzenberg wrote:

> According to Enache Adrian:
> > Just a cast to void* 'if ((void*)&func) ...' will probably get this right --
>
> Unfortunately not.  You must cast, but void* isn't a portable choice.
>
> Function pointers are not guaranteed castable to any data pointer
> type, not even void*.  They're guaranteed castable among each other,
> though (as long as you get them back to their original types before
> calling through them (which we aren't doing anyway)).
>
> So this should be portable:
>
>    typedef void VFUNC();
>    if ((VFUNC*)func != (VFUNC*)main) { ... }
>
> PS: Note that the "&" before a function name is entirely unnecessary.

So it might seem, but it turns out that (for the existing test) the MPE/iX
linker gave Configure the wrong answer unless we used the '&'.  I'm
working on writing down this collected wisdom so we have a place to look
the next time gcc next breaks this test.

-- 
    Andy Dougherty		doughera@lafayette.edu

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About