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

4 次查看(过去 30 天)
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