what does this do ?

Dave Hylands dhylands at gmail.com
Mon Jan 14 01:14:50 EST 2013


Hi,

On Sun, Jan 13, 2013 at 12:09 PM, horseriver <horserivers at gmail.com> wrote:
>
> On Sun, Jan 13, 2013 at 09:27:45PM -0800, Dave Hylands wrote:
> > Hi,
> >
> > On Sun, Jan 13, 2013 at 11:29 AM, horseriver <horserivers at gmail.com>
wrote:
> > >
> > > hi:
> > >
> > >   In kernel code . some function is defined  by
> >  __attribute__((__section__(".initcall" level ".init")))
> > >
> > >   what does this do ?
> >
> > It puts the address of the function in a linker section named
> > .initcallX.init where X is replaced by the level.
>
>    why ".initcall" and level do not connect  together with ## ?
>    As I know , precompiler use ## to connect two strings


That's not quite true. ## is the token pasting operator and is for pasting
together pieces of a token to create a larger token.
http://gcc.gnu.org/onlinedocs/cpp/Concatenation.html

If you have the tokens someVar_  and somethingElse you could token paste
them together to make someVar_somethingElse

The # operator is a for stringizing,which converts non-strings into strings.
http://gcc.gnu.org/onlinedocs/cpp/Stringification.html#Stringification

In C and C++ you can "paste" strings together by just putting them one
after the  other.

const char *x = "This is a long string.";

is 100% identical to

const char *x = "This"     " is a long "    "string.";
http://en.wikipedia.org/wiki/C_syntax#String_literal_concatenation

--
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130113/59e86d2a/attachment.html 


More information about the Kernelnewbies mailing list