I keep getting warnings when I print out int64_t of C

Asked 1 years ago, Updated 1 years ago, 51 views

When int64_t is printed as %d, I keep getting a warning I tried a bigger %lld and it's the same ㅜㅜ lld is the biggest thing I know, what should I do?

#include <stdio.h>
#include <stdint.h>
int64_t my_int = 999999999999999999;
printf("This is my_int: %I64d\n", my_int); //This is also a warning
printf("This is my_int: %lld\n", my_int); //This is also a warning

warning: format ‘%I64d’ expects type ‘int’, but argument 2 has type ‘int64_t’

~/dev/c$ cc -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5664~89/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5664)

c stdint

2022-09-22 22:18

1 Answers

#include <inttypes.h>
int64_t t;
printf("%" PRId64 "\n", t);
#include <inttypes.h>
uint64_t t;
printf("%" PRIu64 "\n", t);

Write PRIx64 and print it in hexadecimal. For more information, see cppreference.com - Fixed width integer types here.


2022-09-22 22:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.