I have a C ++ preprocessor directive that looks something like this:
#if (SOME_NUMBER != 999999999999999) // do stuff #endif
999999999999999 is obviously greater than 2 32 so the value will not fit into a 32-bit integer. Will the preprocessor correctly use the 64-bit integer to allow comparisons, or will it truncate one or both values?
Try using the suffix LL:
#if (SOME_NUMBER != 999999999999999LL) // do stuff #endif
In my gcc this work is fine:
#include <iostream> #define SOME_NUMBER 999999999999999LL int main() { #if (SOME_NUMBER != 999999999999999LL) std::cout << "yes\n"; #endif return 0; }
With or without the LL suffix.
You can try using the constant UINT_MAXdefined in the "limits.h" section:
UINT_MAX
#if (SOME_NUMBER != UINT_MAX) // do stuff #endif
UINT_MAX The value changes depending on the integer size.
Preprocessor arithmetic works as a normal constant expressions (see. Standard, 16.1 / 4), except that intand unsigned intare treated as if they were longand unsigned long. Therefore, if you have a 64-bit type, you can use it as usual.
int
unsigned int
long
unsigned long
Source: https://habr.com/ru/post/1789820/More articles:Problem with delegate and navigation controller - objective-cPHP / MySQL> Refresh field when clicking a link - javascriptASP.NET MVC 3 - Client Validation with a Money Field - asp.net-mvc-3WCF service stops to create threads - multithreadingCapture Modal Dialog Object Using MSHTML / IExplorer - c #T4MVC Html.ActionLink или Html.RouteLink - как добавить цель - t4mvcХорошие поисковые URL-адреса - javascriptHow to check HttpListener () using localhost? - c #Проблема с вставкой данных в таблицу - objective-cWhat design pattern should be used to model Person-Role relationships? - javaAll Articles