Runtime code vs compile time conditional compilation

John Birrell jb at cimlogic.com.au
Sun Feb 15 14:55:39 CST 2004


On Sun, Feb 15, 2004 at 01:13:13PM +0000, Mike Hearn wrote:
> We typically favour runtime checks as Wine is intended to be binary
> portable (compile once, run on lots of different distros etc).

Runtime checks are fine for things that are evaluated at runtime.

In this case, the code that I am questioning is:

if (sizeof(st.st_dev) > sizeof(unsigned long) && st.st_dev > ~0UL)

sizeof() is evaluated at compile time based on the compiler and the
header files you are compiling the sources against. If, as you say,
"compile once, run on lots of distros", then those distros had better
have a consistent definition of struct stat or the code won't
function as the programmer intended.

Note that the code I am questioning does not produce a compiler
warning. The warning comes from code in the if-true path.

The compiler warning attracted my attention to code that if believe
would be better as a #if.

-- 
John Birrell



More information about the wine-devel mailing list