I'm trying to compile a program in Ubuntu environment but I'm having some error saying unknown type name 'uint64_t'
, unknown type name 'uint16_t'
even though I have included cstdint
and any other requirements I believe. It seems like the C++ library support issue.
Does anyone know how to fix this?
To use the uint8_t type alias, you have to include the stdint. h standard header. To avoid a warning, warning: incompatible implicit declaration of built-in function 'printf' , it may be required to explicitly add #include <stdio.
uint16_t is unsigned 16-bit integer. unsigned short int is unsigned short integer, but the size is implementation dependent. The standard only says it's at least 16-bit (i.e, minimum value of UINT_MAX is 65535 ).
Without seeing your code it's very hard to answer. I guess the code does not include cstdint
or stdint.h
, and/or it is not using the std::uint64_t
syntax.
So my answer can only be a simple test/example you can run.
Compile it with:
g++ -Wall -g --std=c++11 int64_test.cpp -o int64_test -lstdc++
The Code "int64_test.cpp":
#include <cstdint>
#include <iostream>
int main( int argc, char **argv )
{
std::uint64_t u64 = 3;
std::int32_t i32 = 141;
std::cout << "u64 = " << u64 << std::endl;
std::cout << "i32 = " << i32 << std::endl;
return 0;
}
This code & compilation works fine on Ubuntu 18.04. I expect it will also work on Ubuntu 14.x
For the sake of completeness, a C version (since this is(was) tagged into the question too)
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h> // Must have this!
int main( int argc, char **argv )
{
uint64_t u64 = 3;
int32_t i32 = 141;
printf( "u64 = %lu\n", u64 );
printf( "i32 = %d\n", i32 );
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With