Pergunta

I have some working Matlab code, which I try to transform into C code using the Matlab coder. I am getting this error:

18   c:\users\bla\project\strcmpi.h(79) : warning C4028: formal parameter 2 different from declaration
19   c:\users\bla\project\strcmpi.h(79) : error C2371: 'strcmpi' : redefinition; different basic types
20           c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\string.h(245) : see declaration of 'strcmpi'
21   NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\cl.EXE"' : return code '0x2'
22   Stop.
23   The make command returned an error of 2
24   'An_error_occurred_during_the_call_to_make' is not recognized as an internal or external command,
25   operable program or batch file.

It looks very C specific to me (I am not a proficient C programmer). Can anyone please point me in the right direction to overcome this error? Thanks.

PS:

Here is some adapted Matlab code:

if(strcmpi(parameters.x,'bladibla') == 1)

    % some code

else

    % some more code

end

where 'parameters' is a struct. I would like to stick to my struct but if there are better ways to achieve the above, especially in the context of the Matlab coder and C, please let me know.

Foi útil?

Solução

The thing about strcmpi() (case-insensitive string comparison) is that it's not a standard C function. Thus, code that relies on it but tries to be portable across platforms sometimes has to provide its own implementation while deferring to the system's implementation if available. In my experience, the project's own strcmpi() implementation will be protected by a configuration option. If you open up c:\users\bla\project\strcmpi.h, you might see code similar to this:

#ifndef CONFIG_STRCMPI_PRESENT
int strcmpi(const char *string1, const char *string2);
#endif  // CONFIG_STRCMPI_PRESENT

If you see this, the trick to getting around the problem will probably be to find the associated config.h file and uncomment the following line:

// #define CONFIG_STRCMPI_PRESENT

This is all just a guess based on my experience with similar issues.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top