[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Checking $host for 64-bit code generation
From: |
Ralf Wildenhues |
Subject: |
Re: Checking $host for 64-bit code generation |
Date: |
Tue, 24 Jun 2008 19:05:17 +0200 |
User-agent: |
Mutt/1.5.17+20080114 (2008-01-14) |
* John Calcote wrote on Tue, Jun 24, 2008 at 05:51:05PM CEST:
> This bit of code is part of a larger chunk of code that fills in a
> Microsoft OS structure for walking the stack:
>
> #ifdef FLM_64BIT
> DWORD64 udDisplacement;
> #else
> DWORD udDisplacement;
> #endif
> if (SymGetSymFromAddr(gv_hMemProcess,
> *puiStack, &udDisplacement, pImgHlpSymbol))
> ...
>
> As you can see here, the OS function SymGetSymFromAddr expects to be
> passed a 64-bit quantity (DWORD64) on 64-bit platforms, and a 32-bit
> quantity (DWORD) on 32-bit platforms. Why didn't they define this
> parameter to use an opaque type, like size_t, for instance?
Well, even if they don't: unless you use SymGetSymFromAddr exactly once
(presumably in a wrapper function), why not do it yourself, and limit
the preprocessor magic to one spot:
#ifdef FLM_64BIT
typedef SymGetSymFromAddrDisp DWORD64;
#else
typedef SymGetSymFromAddrDisp DWORD;
#endif
(/me shudders a bit about the naming convention) and use that
throughout?
> [...] you used the -m32/64
> flag as part of the compiler variable, not the flags variable. This
> would not have occurred to me, but it makes complete sense in hind
> sight. The -mxx flag changes the compiler in a very fundamental way, so
> it's best applied to the $CXX variable.
Well, I used to tell people to put it in CFLAGS/CXXFLAGS. That's wrong
as then the preprocessor is neglected, should it run on its own anywhere
(it most likely will during some configure test). So I started putting
it in both CPPFLAGS and LDFLAGS. That's not so bad, in that it fixes
all interesting languages at once (except maybe un-preprocessed Fortran)
but it does require that these variables are not forgotten anywhere,
even in makefiles not written by automake. Adding it to CC/CXX is
pretty safe.
Cheers,
Ralf