Re: [PATCH] define own version of PRIdPTR on platform where its not available

Gabor Greif <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <CAK-hX0nOVPu9OVTXHTcYR3HWCdFUiOvWM=vtCLpqq-eLuxQwqw@mail.gmail.com>
Of course I use 'offsetof' in the first part of the tool pipeline. The
problem is, though getting the result of it out of the cross-gcc. Here
we cannot simply say

> printf("offsXYZ = %zu", offsetof(XY, Z));

because there is no way to run the cross-gcc output. Instead I do:

> char offsXYZ[offsetof(XY, Z)];

and the inspect the resulting object file with 'nm'. In the second
(i.e. host) gcc
invocation I am not allowed to use 'offsetof' to obtain target values,
so I include
the transformed 'nm' output of the form

> #define offsXYZ 0x12

and compile mkDerivedConstants.c with these constants.

Hope this clears it up.

Cheers,

    Gabor

On 11/5/12, Erik de Castro Lopo <[email protected]> wrote:
> Gabor Greif wrote:
>
>> +1. A configure script will run (almost) till the heat death of the
>> universe.
>>
>> I have a solution on the cross-compiler-alienless branch which does
>> exactly
>> what you propose: feed the relevant headers into the cross-gcc, obtain
>> the offsets/sizes back
>> by 'nm', and massage stuff to obtain all as macros then feed those
>> into mkDerivedConstants.c.
>
> Doesn't the offsetof macro do the right thing for get the offset of
> fields within a struct?
>
>     http://en.wikipedia.org/wiki/Offsetof
>
> Erik
> --
> ----------------------------------------------------------------------
> Erik de Castro Lopo
> http://www.mega-nerd.com/
>
> _______________________________________________
> Cvs-ghc mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/cvs-ghc
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.