Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's a good alternative to uint8_t when it is not provided by the compiler?

I'm using nvcc to compile a CUDA kernel. Unfortunately, nvcc doesn't seem to support uint8_t, although it does support int8_t (!). I'd just as soon not use unsigned char, for portability, readability, and sanity reasons. Is there another good alternative?


Just to forestall any possible misunderstanding, here are some details.

$ 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

Code containing

int8_t test = 0;

is fine, but code containing

uint8_t test = 0;

throws an error message like

test.cu(8): error: identifier "uint8_t" is undefined
like image 452
Josh Bleecher Snyder Avatar asked Nov 29 '22 11:11

Josh Bleecher Snyder


1 Answers

C99 integer types are not "defined by the compiler" - they are defined in <stdint.h>.

Try:

#include <stdint.h>
like image 105
Paul R Avatar answered Jun 03 '23 09:06

Paul R