Why sizeof built in types except char is compiler dependent in C & C++?

前端 未结 3 544
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 05:11

Why are fundamental types in C and C++ not strictly defined like in Java where an int is always 4 bytes and long is 8 bytes, etc. To my knowledge i

3条回答
  •  情话喂你
    2020-12-03 05:41

    The integral data types are not strictly specified so that the compiler can choose whatever is most efficient for the target hardware. However there are some guarantees on minimum sizes of each type (e.g. int is at least 16-bits).

    Check out this page: http://en.cppreference.com/w/cpp/language/types

提交回复
热议问题