当编译器没有提供uint8_t时,它有什么好的替代品?

Jos*_*der 4 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
Run Code Online (Sandbox Code Playgroud)

代码包含

int8_t test = 0;
Run Code Online (Sandbox Code Playgroud)

很好,但代码包含

uint8_t test = 0;
Run Code Online (Sandbox Code Playgroud)

抛出一条错误信息

test.cu(8): error: identifier "uint8_t" is undefined
Run Code Online (Sandbox Code Playgroud)

Pau*_*l R 20

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

尝试:

#include <stdint.h>
Run Code Online (Sandbox Code Playgroud)