Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 字母A和M对预处理器意味着什么_C_Debugging_C Preprocessor - Fatal编程技术网

C 字母A和M对预处理器意味着什么

C 字母A和M对预处理器意味着什么,c,debugging,c-preprocessor,C,Debugging,C Preprocessor,所以我在学习C,我遇到了这个 #ifndef _dbg_h_ #define _dbg_h #include<stdio.h> #include<errno.h> #ifdef NDEBUG #define debug(M,...)// I do not know why M is an argument here #else #define debug(M,...)fprintf(stderr,"DEBUG %s:%d: " M "\n",\ _F

所以我在学习C,我遇到了这个

 #ifndef _dbg_h_
 #define _dbg_h

 #include<stdio.h>
 #include<errno.h>
 #ifdef NDEBUG
 #define debug(M,...)// I do not know why M is an argument here
 #else 
 #define debug(M,...)fprintf(stderr,"DEBUG %s:%d: " M "\n",\
 _FILE_,_LINE_,##_VA_ARGS_)
 #endif
 #define clean_errno()(errno==0?"None":strerror(errno))

 #define log_err(M,...)fprintf(stderr,\"[ERROR](%s:%d: errno: %s)" M "\n"
 _FILE_,_LINE_ ,\clean_errno(),##_VA_ARGS_)
 ...
 #define check(A,M,...)if(!(A)){\         /*why is A an arg here */
  log_err(M,##_VA_ARGS_);errno=0;goto error;}
\ifndef\u dbg\u h_
#定义_dbg_h
#包括
#包括
#ifdef-NDEBUG
#define debug(M,…)//我不知道为什么M在这里是一个参数
#否则
#定义调试(M…)fprintf(标准,“调试%s:%d:“M”\n”\
_文件u、u行u、##VA_u参数u)
#恩迪夫
#定义clean_errno()(errno==0?“无”:strerror(errno))
#定义日志\u err(M,…)fprintf(stderr,\“[错误](%s:%d:errno:%s)“M”\n
_文件u、_行u、\clean_errno()、##(VA_ARGS)
...
#定义检查(A,M,…)如果(!(A)){\/*为什么这里A是arg*/
log_err(M,###VA_ARGS);errno=0;转到错误;}

为什么它们需要M和A作为参数,它们在哪里声明/初始化

名称
M
A
对预处理器没有特殊意义

例如,
M
debug
宏的第一个参数的名称。当名称
M
出现在
debug
宏的定义中时,它将替换为调用
debug
时传递的第一个参数的值

表示它是一个可变的宏,可以接受可变数量的参数

一个简单的例子:

#define MY_MACRO(ARG) (2*(ARG))

printf("%d\n", MY_MACRO(10));

在调用
MY_宏(10)
时,名称
ARG
被替换为
10
,导致整个宏调用扩展到
(2*(10))
。(额外的括号是为了避免运算符优先级的问题。)

正如您已经注意到的,这些是参数。它们像参数一样传递给函数。您的具体问题是什么?你在C语言书中没有找到答案的是什么?还是在线资源?
int n=42-字母n对C编译器意味着什么?n是一个标识符,用于INT类型的变量。此代码中没有M的类型