The "__stringify ()" Macro definition in Linux system is detailed __linux

Source: Internet
Author: User

Include/linux/stringify.h:

#ifndef __linux_stringify_h
#define __LINUX_STRINGIFY_H/

* Indirect stringification.  Doing two levels allows the parameter to be a
 * macro itself.  For example, compile With-dfoo=bar, __stringify (FOO)
 * converts to "bar".
 * *

#define __STRINGIFY_1 (x ...) #x
#define __STRINGIFY (x.   ) __stringify_1 (x)

#endif/  *!__linux_stringify_h * *


Look at the source code above,

__stringify (x ...) the actual expansion of this macro is: #x

The effect is actually to convert x directly into a string. The return value is the string, not the variable name.

Such as

   #define __ATTR (_name,_mode,_show,_store) {/
     . ATTR = {. Name = __stringify (_name),. Mode = _mode},/
     . Show = _sh ow,     /
     . store = _store,     /
    }


Suppose we use __attr this way:

__attr (Var_name, 777, show_function, store_function)

The value that is actually copied to. Attr.name is "Var_name", not the value represented by the Var_name variable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.