gpt4 book ai didi

c - 预处理器算术是否应该与编译所针对的体系结构相匹配?

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

假设我有这个预处理器检查:

#if(-6 & 5)
#error "No 2's complement signed int"
#endif

如果我从二进制补码机器交叉编译到一个补码机器会发生什么。编译器会使用目标机器的算法,还是编译机器的算法?

谢谢

最佳答案

C 2018 6.10.1 4 表示,用于评估 #if 中的表达式和 #elif指令:

… For the purposes of this token conversion and evaluation, all signed integer types and all unsigned integer types act as if they have the same representation as, respectively, the types intmax_t and uintmax_t defined in the header <stdint.h>

这些类型当然是在程序执行过程中使用的,所以它们的行为就是执行环境的行为。

关于c - 预处理器算术是否应该与编译所针对的体系结构相匹配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72066668/

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