我的c ++代码中有一堆int,我需要更改为int32.和我的布尔相同.为了使用int32和bool32,我需要包含哪个头.一旦我制作它们,我该如何声明它们.我能用int32替换int吗?
例如:
int x;
Run Code Online (Sandbox Code Playgroud)
变
int32 x;
Run Code Online (Sandbox Code Playgroud)
当我尝试从int更改为int32时,我遇到了很多错误.这里有几个:
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2086: 'const int x' : redefinition
Edw*_*nge 10
<cstdint>
Run Code Online (Sandbox Code Playgroud)
如果您的编译器支持它,将获得int32_t,C99固定宽度整数类型.
从来没有听说过没有bool32,我无法想象它甚至会产生什么样的感觉.
是的,int只要您的类型保持基础和/或具有默认构造函数/非隐式构造函数,您就可以替换为您的类型......具体取决于使用情况.