Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C define 64bit on 32bit

If I do:

#define TIMEFIXCONST 11644473600

on a 32bit machine, will it overflow or will it be stored as a long long and still work properly? Should I just define a global unsigned long long and use that instead?

like image 529
user105033 Avatar asked May 31 '26 21:05

user105033


2 Answers

A macro is only a text substitution, you can't overflow a macro.
It depends on where do you assign later TIMEFIXCONST.

But as a rule of thumb, when using constants use const int or const long long if you require.

like image 165
Arkaitz Jimenez Avatar answered Jun 02 '26 14:06

Arkaitz Jimenez


The number is not "stored" anywhere. It will just be inserted in the program source code where you use the macro, just as if you had written it directly. But if you want the literal itself to be of type long long, write:

#define TIMEFIXCONST 11644473600LL
like image 42
Thomas Padron-McCarthy Avatar answered Jun 02 '26 15:06

Thomas Padron-McCarthy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!