Re: [PATCH] define own version of PRIdPTR on platform where its not available
Simon Marlow <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.cvs.ghc |
|---|---|
| Message-ID | <[email protected]> |
On 03/11/2012 00:16, Ian Lynagh wrote: > > Hi Karel, > > On Fri, Nov 02, 2012 at 07:39:45PM +0100, Karel Gardas wrote: >> >> I'm curious if this patch is kind of controversial so you are >> reluctant to merge it. If you find any issue with it please let me >> know so I can change it as per your suggestion. I've done this patch >> to un-break GHC HEAD build failure on my solaris 11 box. > > If we're going to go this route, then I think we should do it by > comparing SIZEOF_VOID_P to SIZEOF_INT etc, rather than assuming that > either 'ld' or 'd' is right based on _LP64. > > However, I'm hoping to replace mkDerivedConstants.c with probably a > configure script soon, so that it can produce the right results when > cross-compiling. Yes we need to replace mkDerivedConstants.c with something else for cross compilation, but I really hope it doesn't have to be a configure script :-) Surely it's possible to convince the C compiler to emit struct offsets without having to run the program, somehow? Cheers, Simon >> On 10/30/12 06:59 PM, Karel Gardas wrote: >>> Note that PRIdPTR is considered as linux-ism so it's not available on platforms >>> like Solaris, although some other free Unix(-like) OSes apparently supports >>> it too. >>> --- >>> includes/mkDerivedConstants.c | 11 +++++++++++ >>> 1 files changed, 11 insertions(+), 0 deletions(-) >>> >>> diff --git a/includes/mkDerivedConstants.c b/includes/mkDerivedConstants.c >>> index 1393112..953b2b5 100644 >>> --- a/includes/mkDerivedConstants.c >>> +++ b/includes/mkDerivedConstants.c >>> @@ -30,6 +30,17 @@ >>> #include<stdio.h> >>> #include<string.h> >>> >>> + >>> +#if !defined(PRIdPTR) >>> +#if defined(_LP64) >>> +/* compiling for 64bit target */ >>> +#define PRIdPTR "ld" >>> +#else >>> +/* compiling for 32bit target */ >>> +#define PRIdPTR "d" >>> +#endif >>> +#endif > > > Thanks > Ian > > > _______________________________________________ > Cvs-ghc mailing list > [email protected] > http://www.haskell.org/mailman/listinfo/cvs-ghc >