相关疑难解决方法(0)

如何在C中打印int64_t类型

C99标准具有整数类型,字节大小类似于int64_t.我使用以下代码:

#include <stdio.h>
#include <stdint.h>
int64_t my_int = 999999999999999999;
printf("This is my_int: %I64d\n", my_int);
Run Code Online (Sandbox Code Playgroud)

我得到这个编译器警告:

warning: format ‘%I64d’ expects type ‘int’, but argument 2 has type ‘int64_t’
Run Code Online (Sandbox Code Playgroud)

我尝试过:

printf("This is my_int: %lld\n", my_int); // long long decimal
Run Code Online (Sandbox Code Playgroud)

但我得到同样的警告.我正在使用这个编译器:

~/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)
Run Code Online (Sandbox Code Playgroud)

我应该使用哪种格式打印my_int变量而不发出警告?

c stdint

270
推荐指数
5
解决办法
37万
查看次数

int64_t的定义

我是C/C++的新手,所以我对基本类型有几个问题:

a)你能解释一下int64_tlong(long int)之间的区别吗?据我所知,两者都是64位整数.有没有理由选择一个而不是另一个?

b)我试图int64_t在网上查找定义,但没有取得多大成功.我是否需要咨询这些问题的权威来源?

c)对于使用int64_t编译的代码,我目前包括<iostream>,这对我来说没有多大意义.还有其他包含提供声明int64_t吗?

c c++ integer long-integer

63
推荐指数
5
解决办法
11万
查看次数

我应该如何在Objective-C中声明一个long?NSInteger合适吗?

我看到NSInteger经常使用typedef它并且iPhone上的它很长,所以从技术上来说,当我期望int(64)值时,我可以使用它.但是,我应该更明确地使用类似int64_t或长期的东西吗?使用多长时间的缺点是什么?

iphone objective-c

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

c ×2

c++ ×1

integer ×1

iphone ×1

long-integer ×1

objective-c ×1

stdint ×1