utils/magic.h pointertype prefer use of 'long' instead of 'int'

It is usual for a pointer to require the largest width, while some
platforms might have an 'int' that is smaller than a pointer width.

This reverses the detection order to find.

Note since C99 there is <stdint.h> with type 'intmax_t' which
serves a similar purpose.

SonarCloud reports a concern with this on many lines where used.
"An integral type is too small to hold a pointer value."
https://sonarcloud.io/project/issues?open=AZJB17ZoNGfDNup0RkY_&id=dlmiles_magic
This commit is contained in:
Darryl L. Miles 2024-09-29 23:00:00 +01:00 committed by Tim Edwards
parent a0aea2aa2e
commit 0cea17e801
1 changed files with 4 additions and 4 deletions

View File

@ -36,12 +36,12 @@
#define SIZEOF_VOID_P SIZEOF_UNSIGNED_INT
#endif
#if SIZEOF_VOID_P == SIZEOF_UNSIGNED_INT
typedef unsigned int pointertype;
typedef signed int spointertype;
#elif SIZEOF_VOID_P == SIZEOF_UNSIGNED_LONG
#if SIZEOF_VOID_P == SIZEOF_UNSIGNED_LONG
typedef unsigned long pointertype;
typedef signed long spointertype;
#elif SIZEOF_VOID_P == SIZEOF_UNSIGNED_INT
typedef unsigned int pointertype;
typedef signed int spointertype;
#else
ERROR: Cannot compile without knowing the size of a pointer. See utils/magic.h
#endif