0

I came across the following declaration in the device driver programming:

static int __init sum_init(void)

I have seen static int sum_init(void). Why does the above declaration not give compilation errors?

Angus
  • 12,133
  • 29
  • 96
  • 151
  • 3
    Take a look here: http://stackoverflow.com/questions/8832114/what-does-init-mean-in-this-linux-kernel-code and here http://www.tldp.org/LDP/lkmpg/2.4/html/x281.htm – MByD Nov 24 '13 at 16:18
  • Thanks for the links Binyamin – Angus Nov 24 '13 at 16:33

2 Answers2

2

Because probably __init is some sort of #define that is assigned to anything that won't cause a compilation error.

#define __init

Or...

#define __init __section(.init.text) __cold notrace
mcleod_ideafix
  • 11,128
  • 2
  • 24
  • 32
  • That is usually not correct ( in context of linux device drivers) – MByD Nov 24 '13 at 16:21
  • Clarified :) I didn't realize the poster is speaking about Linux drivers. Anyway, __init is just a macro that could expand to nothing, or to something that makes no harm. The confussion seems to be that the poster is not familiarized with GCC extensions to function declarations. – mcleod_ideafix Nov 24 '13 at 16:26
-1

Its just like saying:

static int __init sum_init()

{

    return 0;

}

It doesn't return any value so no errors were occurred.