
How to get s-function builder to generate c++ style cpp files for compilation with object support?
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
To whom it may concern,
I am having trouble using the s-function builder application to build a mex file for use in simulink. I wish to include a class definition and header similar to that seen in the included in the included example permutation (found here open_system('sfbuilder_permutation')). This example builds fine with no problems on my computer (windows 10, Matlab R2017B, visual studio 2017 c/c++ compiler).
The problem is that when I build even the simplest class, and link it, I get the following error: c:\scratch\working code projects\simulink\blarg2\BLARG2.hpp(1): error C2061: syntax error: identifier 'BLARG2'

Without trying to lead the witness, this appears to be an error thrown by Visual Studio not recognising the identifier "class". It is parsing the files as if they were c files.
I can remedy this error by manually taking the output .c and .h files, renaming them as .cpp and .hpp files and compiling using mex from the command window. Howcome the matlab example permutation generates the correct .cpp and .hpp files (see below)?

I have included a very simple example, where only only the header for the class BLARG2 is being included, and an object is not even instantiated and pointed to by pWork. Any thoughts why this is happening?
Thank you in advance,
Steve
0 comentarios
Respuestas (2)
  Enrique Marti
 el 1 de Mzo. de 2018
        
      Editada: Enrique Marti
 el 1 de Mzo. de 2018
  
      You can change that in the Model Configuration Parameters of the parent Simulink model. In Code Generation section, change Language from C to C++.
After that, your S-Function builder will generate hpp/cpp files.

0 comentarios
  Muhammad HAMZA
 el 21 de En. de 2019
        
      Editada: Muhammad HAMZA
 el 21 de En. de 2019
  
      i have this issue while building "s-function builder" kindly provide expert openion
C:\s_func_calc_power.c not found; check that you are in the correct current folder, and check the spelling of 'C:\s_func_calc_power.c'.
0 comentarios
Ver también
Categorías
				Más información sobre Simulink Coder en Help Center y File Exchange.
			
	Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


