[英]Matlab code to C using Matlab coder
我有一些有效的Matlab代碼,我嘗試使用Matlab編碼器將其轉換為C代碼。 我收到此錯誤:
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.
對於我來說,它看起來非常像C(我不是一個熟練的C程序員)。 誰能指出我正確的方向來克服這個錯誤? 謝謝。
PS:
這是一些經過修改的Matlab代碼:
if(strcmpi(parameters.x,'bladibla') == 1)
% some code
else
% some more code
end
其中“參數”是一個結構。 我想堅持我的結構,但是如果有更好的方法來實現上述目標,尤其是在Matlab編碼器和C的情況下,請告訴我。
關於strcmpi()(不區分大小寫的字符串比較)的問題在於,它不是標准的C函數。 因此,依賴於它但試圖跨平台移植的代碼有時必須提供自己的實現,同時還要遵循系統的實現(如果可用)。 以我的經驗,項目自己的strcmpi()實現將受到配置選項的保護。 如果打開c:\\ users \\ bla \\ project \\ strcmpi.h,可能會看到類似以下的代碼:
#ifndef CONFIG_STRCMPI_PRESENT
int strcmpi(const char *string1, const char *string2);
#endif // CONFIG_STRCMPI_PRESENT
如果看到此消息,解決此問題的技巧可能是找到關聯的config.h文件並取消注釋以下行:
// #define CONFIG_STRCMPI_PRESENT
這些都是根據我對類似問題的經驗得出的猜測。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.