I'm currently working on porting some C files that fit in 32-bit Matlab to 64-bit Matlab.
In doing so, I came across two types: one of the Matlab people and one that is the C standard.
This is what the Matlab documentation says about mwSize:
mwSize (C and Fortran)
Type for size values
Description
mwSize is a type that represents size values, such as array sizes. Use this feature for cross-platform flexibility. By default, mwSize is equivalent to int in C. When using the mex -largeArrayDims switch, mwSize is equivalent to size_t in C. In Fortran, mwSize is equivalent to INTEGER * 4 or INTEGER * 8 based on platform and compilation flags.
This is what Wikipedia says about size_t:
size_t is an unsigned data type defined by several C / C ++ standards (for example, the C99 ISO / IEC 9899 standard), which is defined in stddef.h. [1] It can be further imported by including stdlib.h, since this internal file includes stddef.h [2].
This type is used to represent the size of an object. Library functions that accept or return sizes expect them to be of this type or have a return_type of size_t. In addition, the most commonly used size size operator for the compiler should evaluate to a value compatible with size_t.
The actual type of size_t is platform dependent; a common mistake is to assume that size_t matches unsigned int, which can lead to programming errors [3] [4] when switching from 32 to 64-bit architecture, for example.
As far as I can see, these types are actually the same. My questions are: 1) They? 2) If so, which one will be considered the best programmatic taste for use. Ideally, we would like our code to be compatible with future Matlab releases. I assume the answer will be mwSize, but I'm not sure.
Edit: I have to add that Matlab people use both. For example,
size_t mxGetN(const mxArray *pm);
is a function that returns the number of mxArray columns. However, when you create a matrix, we use
mxArray *mxCreateDoubleMatrix(mwSize m, mwSize n, mxComplexity ComplexFlag);
where the input should obviously be mwSize.