V
vib
Hi there,
I have seen code which use #ifdef-#else-#endif directive to make sure
not duplicate declaration of variables. From the code below, I could
understand the reason behind of using the
#ifndef __KERNEL_H_
#define __KERNEL_H_.
However, as for the #ifdef __KERNEL_DEF
#undef __KERNEL_DEF
TASK taskreg[2];
#else
extern TASK taskreg[2];
#endif
, isn't that unnecesssary? As the first, one can write it without it,
but with a little more planning. and secondly I don't see many using
this construct.
Perhaps I am ignorant about the benefit of that construct. Appreciate
your comments.
Thanks
vib
-----
#ifndef __KERNEL_H_
#define __KERNEL_H_
typedef struct task_reg_type
{
int stack;
int taskreq;
} TASK;
#ifdef __KERNEL_DEF
#undef __KERNEL_DEF
TASK taskreg[2];
#else
extern TASK taskreg[2];
#endif
#endif
------
I have seen code which use #ifdef-#else-#endif directive to make sure
not duplicate declaration of variables. From the code below, I could
understand the reason behind of using the
#ifndef __KERNEL_H_
#define __KERNEL_H_.
However, as for the #ifdef __KERNEL_DEF
#undef __KERNEL_DEF
TASK taskreg[2];
#else
extern TASK taskreg[2];
#endif
, isn't that unnecesssary? As the first, one can write it without it,
but with a little more planning. and secondly I don't see many using
this construct.
Perhaps I am ignorant about the benefit of that construct. Appreciate
your comments.
Thanks
vib
-----
#ifndef __KERNEL_H_
#define __KERNEL_H_
typedef struct task_reg_type
{
int stack;
int taskreq;
} TASK;
#ifdef __KERNEL_DEF
#undef __KERNEL_DEF
TASK taskreg[2];
#else
extern TASK taskreg[2];
#endif
#endif
------