MATLAB: Am I getting a C2371 error when trying to compile MEX-function from C-code in MATLAB 7.6 (R2008a)

c2371MATLABredefinition

I am trying to compile a MEX-function in MATLAB 7.6 (R2008a) using the following command:
mex 'EKF.c' -I'.' -g
If I select LCC-win32 as my compiler, I do not see any errors. If I select either Microsoft Visual C++ 2005 or Microsoft Visual Studio 2008 as the compiler, and then try to compile the MEX-function using the same command shown above, I receive multiple errors of the following form:
error...C:\Documents and Settings\bmartos\Desktop\IMU+GPS\SfunctionsPaulBizard\EKF.c(997) : error C2371: 'kalmanUpdate' : redefinition; different basic types

Best Answer

The reason for the C2371 error in Microsoft Visual Studio is that a function that is being called is not declared previous to the first time it is called. To resolve this issue, create a header file that contains declarations of all of the functions in the code, and include it in the .c file. The reason that you experience this error with Microsoft Visual Studio, and not with LCC is because Microsoft Visual Studio is stricter than LCC in this respect.