int和signed int声明之间的区别 [英] Difference between int and signed int declaration
问题描述
我正在阅读一些有关嵌入式编程的教程,其中一个教程说 int
和 signed int
不同,但确实不解释如何或为什么。
I am reading some tutorials on embedded programming and one of them says int
and signed int
are different but does not explain how or why.
我理解为什么 unsigned int
和 int
不同,但是 int
和 signed int
不同对我来说是新的。
I understand why unsigned int
and int
are different but int
and signed int
being different is a new one for me.
推荐答案
这仅出于历史原因。今天,无论何时声明 int
,您都会得到一个 signed int
。即使今天的编译器,您可能会看到的唯一区别是 char
与 signed char
的区别(并且在分配文字字符串时值得注意),但不能使用 int
。
It is for historical reasons only. Today whenever you declare int
you get a signed int
. The only point where you might see a difference even with today's compilers is with char
versus signed char
which are different by specification (and notable when assigning a literal string) but not with int
.
这篇关于int和signed int声明之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!