<<< Date Index >>>     <<< Thread Index >>>

Re: 1.5.8 build failure on Solaris 8



On Fri, Mar 04, 2005 at 04:07:32PM +0000, Aaron Crane wrote:
> Oswald Buddenhagen writes:
> > after including the standard headers, alias the standard functions to
> > some "namespace-clean" names and undef them afterwards.
> > 
> > #include <unistd.h>
> > #define posix_lseek(a,b,c) lseek(a,b,c)
> > #ifdef lseek
> > # undef lseek
> > #endif
> 
> Given the '#undef lseek', defining another name isn't necessary.
>
but you want to use lseek (or any of the other wrapped functions),
otherwise you wouldn't have included the header in the first place.

> (And I'd even argue that it's slightly harmful -- you're stepping on
> yet more parts of the global namespace, but you still can't use "open"
> as a name with external linkage.)
> 
nobody wants to create a global symbol with that name. we are talking
about structure members, which have no linker symbol associated with
them at all.

> As for the undef itself: as I pointed out, doing that causes nasty
> differences between
> 
>   #include <unistd.h>
>   #include "mutt_socket.h"
> 
> and
> 
>   #include "mutt_socket.h"
>   #include <unistd.h>
> 
sure it does. ugly problems often require ugly solutions (read:
workarounds).

> > open() is a nightmare by itself, because it is a varargs function
> > ...
> 
> As long as you're not trying to define a macro that hides the global
> open() name (and as long as there's a declaration in scope for it when
> you call it) that shouldn't cause any problems.
> 
it is a problem. either the header assumes the preprocessor eats some
type of varargs macros, in which case it will create a macro with
parameters - in this case we have to know about this syntax as well to
create an alias. or it assumes cpp is dumb does not and just #defines open
open64 (or something), in which case even "your" trick would fail -
you'd just have to include the "bad" header in the file you are defining
the structure in, so both your declarations and references get messed up
equally.

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.