How do you get MATLAB Coder to use -c99 rather than -ansi?

조회 수: 4 (최근 30일)
Alexander Mont
Alexander Mont 2015년 2월 9일
답변: John Elliott 2015년 2월 17일
I have a function that I am trying to convert to MEX using Matlab Coder. This function has a call to coder.ceval(), which uses an external function which needs to be compiled using -c99 rather than -ansi. However, the build fails, and the build log says it is using -ansi. How do I change it to use -c99? My understanding is that normally you do this by editing the mexopts.sh file. However in this case, the mexopts.sh file appears to be auto-generated in the directory codegen/mex/<entry-point-file-name>, and is marked as read only, presumably indicating that it is not supposed to be altered. I tried to add "-c99" to the "Additional flags" under "More settings" under the Build tab, but that didn't seem to do anything. What is the correct way to get it to use -c99 instead of -ansi? Am I supposed to use "chmod +w" on mexopts.sh so that I can edit it?

답변 (1개)

John Elliott
John Elliott 2015년 2월 17일
Hi Alexander,
I think that there are a number of solutions. First, you can do as you suggest, and modify the generated mexopts.sh file. Alternatively, and perhaps preferably, you could pre-compile the C files that use C99, and use the generated object files or library file with the codegen command, rather than the C99 C source files. This latter solution assumes that the C99 C files don't depend on the C or H files generated by the codegen command.
-John

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by