Skip to content

Comparison to -1 of unsigned integer. #2054

Answered by orcmid
ghost asked this question in Q&A
Discussion options

You must be logged in to vote

This looks like a tricky way to avoid UINT_MAX (from limits.h) when glInternalFormat might be a different unsigned size than unsigned int and the max value is some sort of flag case.

I just compiled a small program using cl.exe with no options and that is exactly what happens. I assigned -1 to unsigned int glInternalFormat and the comparison != -1 failed and comparison with UINT_MAX succeeded.

That's a beautiful hack. A better solution might be to declare a const (better than #define) with the intended value and a big XXX comment with it, all in rlgl.h

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@ghost
Comment options

Comment options

You must be logged in to vote
1 reply
@orcmid
Comment options

Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@orcmid
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants