lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Andrew, I appreciate your attention to this matter but I have to disagree.

You cited C89 standard.
Also casting inside preprocessor macros isn't compliant to C standards.

IMHO we have to find a better solution.

As a work-around...

#if defined(SIZE_MAX)
    #define MAX_SIZET SIZE_MAX
#else
    #warning "This can break compilation, isn't compliant to C99"
    #define MAX_SIZET ((size_t)(~(size_t)0))
#endif

M

On Fri, 22 May 2020 at 16:49, Andrew Gierth <andrew@tao11.riddles.org.uk> wrote:
>>>>> "Massimo" == Massimo Sala <massimo.sala.71@gmail.com> writes:

 Massimo> I don't get the purpose of MAX_SIZET instead of the plain
 Massimo> SIZE_MAX.

SIZE_MAX doesn't exist in c89 as far as I know.

Though the MAX_SIZET definition is unnecessarily complicated, it
suffices to use (size_t)-1, but this isn't a strictly valid _expression_
in preprocessor conditionals either because of the cast.

--
Andrew.