简体   繁体   English

在预处理程序指令中结合##和_type

[英]combining ## and _type in preprocessor directives

What is the purpose of the usage thread##_type in this code snippet? 此代码段中的用法thread##_type的用途是什么? I understand that underscore t (_t) is used as a convention for naming to identify types, as is underscore type (_type) , often in typedef statements. 我知道下划线t (_t)用作命名来标识类型的约定,下划线类型(_type)经常在typedef语句中使用。 I also understand ## in macros indicate concatenation. 我也理解macros ##表示串联。 Does _type has any purpose other than this? _type还有其他用途吗? (like the usage of double underscore __FILE__ )? (例如使用双下划线__FILE__ )?

#define THREAD_TYPE(thread)                         
typedef struct                                      \
{                                                   \
   pthread_t pthread;                               \
   int err;                                         \
} thread##_type;

_type在C中没有特殊含义。此代码_type作者选择的方式修饰名称,仅此而已。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM