Convert from int to int32

I have a bunch of ints in my C ++ code that I need to change to int32. Same thing with my fool. Which header do I need to include in order to use int32 and bool32. Just like I declare them when I make them. Can I just replace int with int32?

For instance:

int x; 

becomes

 int32 x; 

I get a lot of errors when I try to switch from int to int32. Here are a few:

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

error C2086: 'const int x' : redefinition

+4
source share
3 answers

In windows you can use the built-in type __int32. I have never heard of a 32-bit bool, but you can just use typedef for this.

+1
source
 <cstdint> 

If your compiler supports it, you will get int32_t, an integer type of fixed width C99.

I never heard of bool32, and I can’t imagine what meaning it could make.

Yes, you can simply replace int with your type if your type remains fundamental and / or has a constructor constructor / implicit default constructor ... depending on usage.

+10
source

It might be better to have a typedef instead of the actual data type.

eg.

 typedef int my_int; .... my_int var; 

becomes:

 typedef int32 my_int; .... my_int var; 

That way you can just change one line of code to change all instances of int to int32.

+1
source

Source: https://habr.com/ru/post/1337835/


All Articles