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 <mle...@mega-nerd.com> 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 > Cvs-ghc@haskell.org > http://www.haskell.org/mailman/listinfo/cvs-ghc > _______________________________________________ Cvs-ghc mailing list Cvs-ghc@haskell.org http://www.haskell.org/mailman/listinfo/cvs-ghc