Reputation: 110600
Hi I need some help in understand some C code:
#if 0
some C code 1
#elif 0
static int8 arry[10];
#pragma Align_to(32, arry)
ASSERT(((int8ptr_t)arry) & 15) == 0)
#else
ASSERT(((int8ptr_t)arry) & 15) == 0)
#endif
My questions:
Is only the #else
part compiled?
What is the meaning of #pragma Align_to(32, arry)
in the #elif 0
case?
Upvotes: 2
Views: 193
Reputation: 154305
Yes, the #else
part is what is compiled.
The #pragma
directive is a compiler specific directive. As you compiler was not specified, it could mean anything.
In your case #pragma Align_to(32, arry)
, likely tells the compiler to insure variable 'arry' is place in memory on a 32 byte boundary. This is typically for performance reasons or compatibility concerns. You may also want to look into the keyword __attribute__
use to control similar variable attributes.
Upvotes: 0
Reputation: 72697
Answer to 1: Yes, but note that even the parts within #if 0
etc. must consist of valid preprocessing tokens. This means that this will fail with a diagnostic:
#if 0
That's what C is all about
#endif
because there's an unterminated character constant introduced by the lone '
. Same goes for unterminated string literals.
Answer to 2: The pragma
is a hint to the compiler that the address of arry
shall be aligned on a multiple of 32.
Upvotes: 0
Reputation: 23634
Actually better way to answer is ask compiler - use g++ -E
or MSVC: cl /EP
to print what is really compiled
Upvotes: 2