query about use of IFDEFS
hi,
which of the following be acceptable in the linux kernel ?
1. first choice, you've put the static inline in the header
---------------------------------------
foo.h:
#ifdef CONFIG_BAR
void foo_init(void);
#else
static void __inline__ foo_init(void);
foo.c:
#ifdef CONFIG_BAR
void foo_init(void)
{
do_some_stuff_here();
}#else
#endif
2. you've left the conditional compilation only in the .c file
----------------------------------------
foo.h:
void foo_init(void);
foo.c:
void foo_init (void)
{
#ifdef CONFIG_BAR
do_some_stuff_here();#else
#endif
}
Quoted 2 lines · Manik Raina
which of the following be acceptable in the linux kernel ? [...]
The first. You want the code itself to be clean and clear; free of ifdefs.
So in your header files you ifdef as needed. The simplest example of this would be with a define:
#ifdef CONFIG_SMP #define special_smp_thing() whatever_smp() #else #define special_smp_thing() #endif Robert Love