Can I use generated code in a user-defined MFC application?
10 次查看(过去 30 天)
显示 更早的评论
I am trying to make a MFC application with Microsoft Visual Studio 2010 with the goal of running code generated by simulink coder from a windows (FormView) form.
I have included all necessary files in the project, I have renamed the 'main' function in rt_main.c, I have inserted #include rt_main.c in the formview header file, and I have created a routine that calls rt_OneStep() regulary based on a user-defined execution rate. Methods that take care of the initialization and the output of the model are also in place.
However, I get two errors pointing to windns.h, a file that is included in the 'external dependencies' of the microsoft visual studio solution, when making a MFC application. I have made working MFC applications where this same file is included, so I know it has to be caused by some kind of interaction with the matlab/simulink include-files or with the generated code.
The errors both read "error C2059: Syntax Error : 'constant' " and point to the following section of code in windns.h:
DNS_MX_DATAW MX, Mx,
AFSDB, Afsdb,
RT, Rt; //error points here
DNS_TXT_DATAW HINFO, Hinfo,
ISDN, Isdn,
TXT, Txt,
X25;
This section of code appears twice in the file, hence the two errors. I know someone who has used a similar method to implement simulink generated code into a Microsoft Visual Studio solution (also a MFC application), but with an older version of Visual Studio. His program works fine, but when I load his solution into Visual Studio 2010 I get the same errors. Does anyone know what causes this, and how to get around it?
*EDIT: I have discovered that one of the lines in the preprocessor definitions I have added to the project from the defines.txt file generated by simulink coder reads 'RT'. I assume this must be causing the error. What is the function of this line? Can I remove or adjust it to avoid the error? I will try some things but I feel it's dangerous to modify things without fully grasping the consequences. A quick response would be much appreciated, thanks in advance.
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!