Difference between int and signed int declaration

 ̄綄美尐妖づ 提交于 2019-12-05 15:52:22

问题


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.

I understand why unsigned int and int are different but int and signed int being different is a new one for me.


回答1:


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.




回答2:


As far as I know the difference exists only for char data type. Where char a; can be signed char a; or unsigned char a; depending on compiler options. As this article says. (--signed_chars) For int data types, there is no difference between int and signed int.



来源:https://stackoverflow.com/questions/12952553/difference-between-int-and-signed-int-declaration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!