compiler-construction - 当编译器不提供 uint8_t 时,有什么好的替代方法?

标签 compiler-construction types cuda

我正在使用 nvcc 来编译 CUDA 内核。不幸的是,nvcc 似乎不支持 uint8_t ,虽然它确实支持 int8_t (!)。我会尽快不使用 unsigned char ,出于便携性、可读性和理智的原因。还有其他好的选择吗?

为了防止任何可能的误解,这里有一些细节。

$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2010 NVIDIA Corporation
Built on Mon_Jun__7_18:56:31_PDT_2010
Cuda compilation tools, release 3.1, V0.2.1221

代码包含
int8_t test = 0;

很好,但代码包含
uint8_t test = 0;

抛出一条错误消息,如
test.cu(8): error: identifier "uint8_t" is undefined

最佳答案

C99 整数类型不是“由编译器定义的”——它们在 <stdint.h> 中定义.

尝试:

#include <stdint.h>

关于compiler-construction - 当编译器不提供 uint8_t 时,有什么好的替代方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4189243/

相关文章:

javascript - 从方法对象获取窄类型

c++ - 在 Qt 中设计 IDE;有没有我可以使用的已经制作好的编译器包?

compiler-construction - 为 CLR 实现函数式语言(或者,关于 F# 实现的论文)

c++ - 使用模板无限编译

将 32 位整数值转换为无符号 16 位整数

cuda 6统一内存段错误

c++ - 此代码在我的计算机上编译并运行但不在服务器上

c# - 如何绕过指定通用参数类型的需要?

大图像的 Cuda 分配/内存 tTime

c++ - 编译 .cu 与 .cpp : Compiler errors even without any CUDA code