3

I am going through beginner's kernel module exercises. In several sources, they define the following macros:

#define MODULE
#define LINUX
#define __KERNEL__

But kbuild warns:

warning: "MODULE" redefined [enabled by default]
...
warning: "__KERNEL__" redefined [enabled by default]

So my questions are:

  1. What are these definitions for anyway?
  2. Why would "redefinition" require a warning? Merely because in general it implies that a previous (desired) value for the macro has been overridden?
  3. Why not put these definitions in #ifndef blocks?
jsj
  • 9,019
  • 17
  • 58
  • 103
  • Maybe you should identify some of those sources? Maybe the sources are out of date with current kernel building. You could `#undef` those before defining them, which will help if the complaint is about your code. If the redefinition is occurring in the kernel code, then it is clear that the kernel does not expect you to define them. – Jonathan Leffler May 16 '14 at 05:56
  • Are you sure you're using the right exercises for your kernel version? I ran in to these warnings while following The Linux Kernel Module Programming Guide v. 2.4; I should have been using the guide for 2.6: http://www.tldp.org/LDP/lkmpg/ – rphv Sep 12 '14 at 19:05

0 Answers0