gpt4 book ai didi

ios - 访问 Xcode LLVM 处理器宏

转载 作者:行者123 更新时间:2023-11-29 12:01:12 24 4
gpt4 key购买 nike

在“build设置”选项卡下的“Apple LLVM 7.0 - 预处理”部分,我将预处理器宏定义为:

HUBNAME=myhub

在我的代码中,我尝试将 HUBNAME 的值作为字符串引用:

SBNotificationHub* hub = [[SBNotificationHub alloc] initWithConnectionString:HUBLISTENACCESS notificationHubPath:HUBNAME];

但 Xcode 认为“myhub”是我的变量的名称:

Use of undeclared identifier 'myhub'

谁能帮我弄清楚如何以字符串形式访问“myhub”?

最佳答案

类似于TO_STR(arg)=#arg HUBNAME=TO_STR("myhub")? (或者只是 TO_STR(myhub) 不带引号。)

NSLog(@"%s", HUBNAME); // SO36947532[13085:4401425] myhub

来自 GNU:

3.4 Stringification

Sometimes you may want to convert a macro argument into a string constant. Parameters are not replaced inside string constants, but you can use the # preprocessing operator instead. When a macro parameter is used with a leading #, the preprocessor replaces it with the literal text of the actual argument, converted to a string constant. Unlike normal parameter replacement, the argument is not macro-expanded first. This is called stringification.

Xcode

关于ios - 访问 Xcode LLVM 处理器宏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36947532/

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