gpt4 book ai didi

c - 如何使用定义预处理器来定义函数指针?

转载 作者:行者123 更新时间:2023-11-30 19:35:22 26 4
gpt4 key购买 nike

我想为函数指针 *creatingI() 创建一个预处理器,但我做不到。怎么了?

#define  *creatingI() *CreatInt();

错误:

error C2007: #define syntax

最佳答案

指令define后面的名称必须是标识符,因此您需要编写类似函数的宏,其名称以{下划线,字母}开头,后跟{下划线、字母、数字}。

所以只需删除通配符*:

#define  creatingI() *CreatInt();
<小时/>

从 C99 6.10 开始:

# define identifier replacement-list new-line

从 C99 6.4.2 开始:

Syntax

identifier:

identifier-nondigit

identifier identifier-nondigit

identifier digit

identifier-nondigit:

nondigit

universal-character-name

other implementation-defined characters

nondigit:

one of

_ a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V WX Y Z

digit:

one of 0 1 2 3 4 5 6 7 8 9

关于c - 如何使用定义预处理器来定义函数指针?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42754436/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com