The following code extract works fine in the 32bit build environments, and
also in the AMD64
build environment, but fails with a compilation error in the IA64 build
environment.
if (Ext->InterruptsEnabled)
WRITE_REGISTER_ULONG(Ext->bar0->gcsr, foo);
else
WRITE_REGISTER_ULONG(Ext->bar0->gcsr, bar);
The compilation error is “illegal else without matching if”
if I write it
if (Ext->InterruptsEnabled)
{
WRITE_REGISTER_ULONG(Ext->bar0->gcsr, foo);
}
else
{
WRITE_REGISTER_ULONG(Ext->bar0->gcsr, bar);
}
It works fine under all environments.
The reason is that the functions are defined as functions for the 32 bit and
AMD64 environments, but in the IA64 environment the functions are macros
defined like the following
#define WRITE_REGISTER_XXX(x,y) { \
*(volatile XXX * const)(x) = y; \
KeFlushWriteBuffer(); \
}
Oh, well; I guess I’ll have to remember to use {}.
I note, in passing, that it doesn’t have to be this way. If the macros had
been defined as
#define WRITE_REGISTER_XXX(x,y) (VOID)(*(volatile XXX * const)(x) = y,
KeFlushWriteBuffer())
then my code works with or without enclosing {}.
I thought that the authors of WRITE_REGISTER_XXX had forgotten about the
comma operator until I
looked at the definitions of READ_REGISTER_XXX, where they use it.
Don