M
Mohammad Omer Nasir
I was read Linux kernel code [linux-2.6.19] in which I saw few define
macro defines in functions. The snap of the function is following and
file name "err_ev6.c".
static int
ev6_parse_cbox(u64 c_addr, u64 c1_syn, u64 c2_syn,
u64 c_stat, u64 c_sts, int print)
{
char *sourcename[] = { "UNKNOWN", "UNKNOWN", "UNKNOWN",
"MEMORY", "BCACHE", "DCACHE",
"BCACHE PROBE", "BCACHE PROBE" };
char *streamname[] = { "D", "I" };
char *bitsname[] = { "SINGLE", "DOUBLE" };
int status = MCHK_DISPOSITION_REPORT;
int source = -1, stream = -1, bits = -1;
#define EV6__C_STAT__BC_PERR (0x01)
#define EV6__C_STAT__DC_PERR (0x02)
#define EV6__C_STAT__DSTREAM_MEM_ERR (0x03)
#define EV6__C_STAT__DSTREAM_BC_ERR (0x04)
..
..
..
}
I was tested following code.
#define AAA 90
void fun( )
{
#define _AAA 100
}
int main()
{
printf( "%d %d", AAA, _AAA );
return 0;
}
The result was "90 100". I am not able to understand, what is the
difference in use of define macro to defines in Global scoop or with in
Function scoop?
Regards,
-aims
macro defines in functions. The snap of the function is following and
file name "err_ev6.c".
static int
ev6_parse_cbox(u64 c_addr, u64 c1_syn, u64 c2_syn,
u64 c_stat, u64 c_sts, int print)
{
char *sourcename[] = { "UNKNOWN", "UNKNOWN", "UNKNOWN",
"MEMORY", "BCACHE", "DCACHE",
"BCACHE PROBE", "BCACHE PROBE" };
char *streamname[] = { "D", "I" };
char *bitsname[] = { "SINGLE", "DOUBLE" };
int status = MCHK_DISPOSITION_REPORT;
int source = -1, stream = -1, bits = -1;
#define EV6__C_STAT__BC_PERR (0x01)
#define EV6__C_STAT__DC_PERR (0x02)
#define EV6__C_STAT__DSTREAM_MEM_ERR (0x03)
#define EV6__C_STAT__DSTREAM_BC_ERR (0x04)
..
..
..
}
I was tested following code.
#define AAA 90
void fun( )
{
#define _AAA 100
}
int main()
{
printf( "%d %d", AAA, _AAA );
return 0;
}
The result was "90 100". I am not able to understand, what is the
difference in use of define macro to defines in Global scoop or with in
Function scoop?
Regards,
-aims