c - -ansi -pedantic C 中的 64 位长度整数

标签 c 64-bit int portability

我想知道是否有等效于 int64_t在 C 中可以在 32 位和 64 位平台上运行,并且符合 ansi 和 pedantic gcc 模式。

我发现这很有趣 post ,但它与 C++ 相关。

我试过用 long long但我得到一个 integer overflow in expression [-WOverflow]错误。此外long long ISO C90 不支持。

我也尝试了这个 post 中的建议,但我还有一个 -WOverflow使用 int64_t 时出错

任何解决方案?

最佳答案

  • 在 C89 中(-ansi 标志要求),没有使用 64 位整数的标准方法。您必须依赖您的实现提供的类型。
  • 在 C99 中,一些实现可能定义 int64_t ,因为它是一个可选类型。至于long long (C99),不能保证它的宽度正好是 64 位。
  • 关于c - -ansi -pedantic C 中的 64 位长度整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16101002/

    相关文章:

    c - 无需借助 `limits.h` 即可确定最大整数值的安全方法

    c - 如何使用 GDB 重定向到不同的位置?

    c - 如何更改 Gtk2 条目中的字段背景颜色?

    c - 如何通过 gcc 临时文件创建进行故障排除

    windows - 启动 Cassandra 服务器错误

    visual-studio - Visual Studio 引用 x64 GAC

    c - 如何从战略上克服段错误?

    .net-3.5 - 如何强制 .NET 应用程序以 32 位模式运行

    java - boolean 值与整数的内存/大小?

    java - 在java中将int转换为char