预处理器算术是否应该匹配汇编目标的架构?

发布于 2025-01-25 15:35:21 字数 404 浏览 3 评论 0 原文

假设我有此预处理检查员检查:

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

如果我从a 机器朝着 ans'nore'noreferrer“> onse's Replectement 机器?编译器会使用目标机器的算术或编译机的算术吗?

Let’s say I have this preprocessor check:

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

What would happen if I cross compiled from, say, a two's complement machine toward a ones' complement machine? Would the compiler use the arithmetic of the target machine, or the one of the compiling machine?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何以笙箫默 2025-02-01 15:35:21

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

…出于该令牌转换和评估的目的,所有签名的整数类型和所有未签名的整数类型都像它们具有与类型相同的表示形式 intmax_t and code> uintmax_t 在标题中定义< stdint.h>

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

C 2018 6.10.1 4 says, for evaluation of expressions in #if and #elif directives:

… 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>

These types are of course used during program execution, so their behaviors are those of the execution environment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文