Marx code predates C99, where int32_t types were codified. Instead, it uses pre-processor logic to make those definitions, e.g. in jdmath.h:
#ifdef SIZEOF_INT
# if SIZEOF_INT == 2
# undef INT16_BASIC_TYPE
# define INT16_BASIC_TYPE int
# else
# if SIZEOF_INT == 4
# undef INT32_BASIC_TYPE
# define INT32_BASIC_TYPE int
# endif
# endif
#endif
which says: If int is 2 bytes long, we can use int for out own type that is called INT16_BASIC_TYPE, if it is 4 bytes long, then we can use it for our own type INT32_BASIC_TYPE and in that way we build up a library of basic types.
We then follow that up with:
To be clear: This approach works on all systems that we have tested and there is no urgency to address it. However, it seems a whole lot simpler to search and replace our own typedef'edint16 with int16_t from the C standard (possibly need to include <stdint.h> if that's not done yet) and add AC_TYPE_INT16_T to configure.ac.
Then, we need to test to make sure I did not overlook some subtle difference with unsigned/signed etc., but basically we should be able to cut a whole lot of pre-processor stuff out, making the code more readable.
Once that is done, the AC_CHECK_SIZEOF_X in all three configure.ac files should also not be necessary any longer. (Not sure they are used in the code currently anywhere.)
Marx code predates C99, where
int32_t
types were codified. Instead, it uses pre-processor logic to make those definitions, e.g. in jdmath.h:which says: If int is 2 bytes long, we can use int for out own type that is called
INT16_BASIC_TYPE
, if it is 4 bytes long, then we can use it for our own typeINT32_BASIC_TYPE
and in that way we build up a library of basic types. We then follow that up with:To be clear: This approach works on all systems that we have tested and there is no urgency to address it. However, it seems a whole lot simpler to search and replace our own typedef'ed
int16
withint16_t
from the C standard (possibly need to include<stdint.h>
if that's not done yet) and addAC_TYPE_INT16_T
toconfigure.ac
.Then, we need to test to make sure I did not overlook some subtle difference with unsigned/signed etc., but basically we should be able to cut a whole lot of pre-processor stuff out, making the code more readable.