When the C compiler finds a function call without having seen a function prototype it assumes a function that returns an int.
You should tell the compiler the correct function signature with the "function prototype":
int* MakeData(int DataCount);
This should be placed in a .h file that will be included in all compilation units that call or define the function.
If you have a static function, that is visible only in the current compilation unit, you can place the prototype (incl. static
) before all functions in that file.
Further you should never cast the return from malloc
. It returns a void*
. In the language C this can be converted to any other pointer type. You get the correct prototype when you #include <stdlib.h>
.