便携式int? [英] Portable int?

查看:62
本文介绍了便携式int?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是好奇,为什么我们只是使用uint8_t或uint16_t例如

来声明一个整数类型的存储,当我们知道int总是

平台依赖?除了M $ Windows和Linux之外,我没有其他

平台的编程经验。


谢谢。

I''m just curious, why don''t we just use uint8_t or uint16_t for example
to declare an integer type storage when we know int is always
platform-dependent? I do not have programming experience on other
platform except M$ Windows and Linux.

Thank you.

推荐答案

Windows和Linux。


谢谢。
Windows and Linux.

Thank you.




Phui Hock < pH值****** @ myway.com>在消息中写道

新闻:a9 ************************** @ posting.google.c om ...

"Phui Hock" <ph******@myway.com> wrote in message
news:a9**************************@posting.google.c om...
我只是好奇,为什么我们不要只使用uint8_t或uint16_t来声明一个整数类型的存储,当我们知道int总是
platform-依赖?我没有其他平台的编程经验,除了M
I''m just curious, why don''t we just use uint8_t or uint16_t for example
to declare an integer type storage when we know int is always
platform-dependent? I do not have programming experience on other
platform except M


Windows和Linux。
Windows and Linux.




Cuz''愚蠢的。原因是int并不总是一个固定的大小[它确实有b $ b b b最小btw]是它意味着一个理想的平台大小。例如。对于

8086它是16位,而对于68000它是32位。


这个想法是我想要一些简单的东西喜欢


int x;

for(x = 0; x< strlen(buf); x ++){

buf [x] = tolower(buf [x]);

}


[或其他] ......变量x应该易于管理[例如不是

在8086上是32位而在68k上不是16位]。


Along总是意味着稍微不方便但范围更大。

但情况并非总是这样。在68k / 386编译器上长对于int来说通常是

的同义词[除非存在数组表达式,因此我们都

知道它们必须是int]。


Tom



Cuz that''s stupid. The reason "int" isn''t always a fixed size [it does have
minimums btw] is that it''s meant to be an ideal platform size. E.g. for the
8086 it''s 16-bits while for the 68000 it''s 32-bits.

The idea is if I want something simple like

int x;
for (x = 0; x < strlen(buf); x++) {
buf[x] = tolower(buf[x]);
}

[or whatever].... the variable "x" should be easily manageable [e.g. not
32-bits on an 8086 and not 16-bits on a 68k].

A "long" was always meant to be "slightly less convenient but larger range".
That''s not always the case though. on 68k/386 compilers "long" is typically
synonymous for "int" [except when array expressions are present cuz we all
know they must be int].

Tom


这篇关于便携式int?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆