@@ -110,6 +110,7 @@ end translateModel;
110110 /* Simulation code for <%dotPath(modelInfo.name)%> generated by the OpenModelica Compiler <%getVersionNr()%>. */
111111 #if !defined(<%modelNamePrefixStr%>__MODEL_H)
112112 #define <%modelNamePrefixStr%>__MODEL_H
113+
113114 #include "openmodelica.h"
114115 #include "openmodelica_func.h"
115116 #include "simulation_data.h"
@@ -122,6 +123,10 @@ end translateModel;
122123 #include "simulation/solver/nonlinearSystem.h"
123124 #include "simulation/solver/mixedSystem.h"
124125
126+ #if defined(__cplusplus)
127+ extern "C" {
128+ #endif
129+
125130 #include < string.h>
126131
127132 #include " <%fileNamePrefix%>_functions.h"
@@ -200,7 +205,12 @@ end translateModel;
200205 #define omp_get_max_threads() 1
201206 #endif
202207
208+ #if defined(__cplusplus)
209+ }
203210 #endif
211+
212+ #endif /* !defined(<%modelNamePrefixStr%>__MODEL_H) */
213+
204214 <%\n%>
205215 >>
206216 end match
@@ -1021,6 +1031,11 @@ template simulationFile(SimCode simCode, String guid, String isModelExchangeFMU)
10211031 >>
10221032 <<
10231033 /* Main Simulation File */
1034+
1035+ #if defined(__cplusplus)
1036+ extern "C" {
1037+ #endif
1038+
10241039 <% simulationFileHeader(simCode.fileNamePrefix)%>
10251040 #include " simulation/solver/events.h"
10261041
@@ -1038,9 +1053,6 @@ template simulationFile(SimCode simCode, String guid, String isModelExchangeFMU)
10381053 /* dummy VARINFO and FILEINFO */
10391054 const FILE_INFO dummyFILE_INFO = omc_dummyFileInfo;
10401055 const VAR_INFO dummyVAR_INFO = omc_dummyVarInfo;
1041- #if defined(__cplusplus)
1042- extern "C" {
1043- #endif
10441056
10451057 <% functionInput(simCode, modelInfo, modelNamePrefixStr)%>
10461058
@@ -1127,10 +1139,6 @@ template simulationFile(SimCode simCode, String guid, String isModelExchangeFMU)
11271139
11281140 <%functionInitializeDataStruc(modelInfo, fileNamePrefix, guid, delayedExps, modelNamePrefixStr, isModelExchangeFMU)%>
11291141
1130- #ifdef __cplusplus
1131- }
1132- #endif
1133-
11341142 static int rml_execution_failed()
11351143 {
11361144 fflush(NULL);
@@ -1165,6 +1173,11 @@ template simulationFile(SimCode simCode, String guid, String isModelExchangeFMU)
11651173 EXIT(res);
11661174 return res;
11671175 }
1176+
1177+ #ifdef __cplusplus
1178+ }
1179+ #endif
1180+
11681181 <%\n%>
11691182 >>
11701183 %>
@@ -5774,7 +5787,7 @@ case SIMCODE(modelInfo=MODELINFO(varInfo=varInfo as VARINFO(__)), delayedExps=DE
57745787 # Makefile generated by OpenModelica
57755788
57765789 # Simulations use -O3 by default
5777- CC=<%if boolOr(Flags.isSet(Flags.PARMODAUTO),acceptParModelicaGrammar()) then 'g++' else '<%makefileParams.ccompiler%>'%>
5790+ CC=<%if boolOr(boolOr( Flags.isSet(Flags.PARMODAUTO),acceptParModelicaGrammar()), boolOr(stringEq(makefileParams.platform, "win32"),stringEq(makefileParams.platform, "win64") )) then 'g++' else '<%makefileParams.ccompiler%>'%>
57785791 CXX=<%makefileParams.cxxcompiler%>
57795792 LINK=<%makefileParams.linker%>
57805793 EXEEXT=<%makefileParams.exeext%>
0 commit comments