Tri-Edge AI
Tri-Edge AI

Reputation: 340

How can I force the size of long to 8-bytes on any arch?

I want my long to be 8 bytes, regardless of whether I'm compiling in 32-bit mode or 64-bit mode. I am using MSVC and I don't care much about cross-platformity at this point. I tried doing things like

#define long __int64

or

typedef __int64 long;

but the first one results in massive compile errors in other files and the second one seems to be unacceptable by the compiler by itself.

Upvotes: 0

Views: 235

Answers (1)

Roee Gavirel
Roee Gavirel

Reputation: 19453

I wouldn't change the default behavior of a reserved type. a better practice is creating a new type if you like and work with it.

think on a case when you include the thirdPartyLib and it "h" file have something like that:

void func1(long number);

When your code includes the "h" file it will see the "number" parameter as 64bit BUT when the original "c" file of the lib included that "h" it can thinks that "number" is a 32bit. That will cause problems in the linkage stage.

Upvotes: 0

Related Questions