question

Craig DIckson avatar image
1 Like"
Craig DIckson asked Phil BoBo edited

How to compile? Getting > 100 errors

Hi-

Trying to compile my model to speed it up some. Win7 Pro, and Visual Studio 13.

Configured FlexSim to see Visual Studio.

flexsim-vs-config.png

Saved, closed, and opened FlexSim. Then I tried to build it:

Build-> Make All Code C++ and then saved

Opened compiler console

Build->Compile model

I got more than 100 errors. What else do I need to do?

Here are the first few errors:

building...

------------------------------ compiling functions ------------------------------

execute(cl /W0 /MT /EHa /c /nologo /Zi /I "C:\Projects\QVC\Simulation_Solution\Milestone 2 Pick Module Only\Model" /I "C:\Program Files\FlexSim 2016 Update 2\program\system\include" all.cpp);

all.cpp

c:\users\craig dickson\appdata\roaming\flexsim\flexsim16.2\compile\all.h(2237) : error C2008: ',' : unexpected in macro definition

c:\users\craig dickson\appdata\roaming\flexsim\flexsim16.2\compile\all.h(2297) : error C2008: '&' : unexpected in macro definition

c:\users\craig dickson\appdata\roaming\flexsim\flexsim16.2\compile\all.h(2298) : error C2143: syntax error : missing ';' before '&'

c:\users\craig dickson\appdata\roaming\flexsim\flexsim16.2\compile\all.h(2298) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

c:\users\craig dickson\appdata\roaming\flexsim\flexsim16.2\compile\all.h(2357) : error C2008: '/' : unexpected in macro definition

c:\users\craig dickson\appdata\roaming\flexsim\flexsim16.2\compile\all.h(2358) : error C2143: syntax error : missing ';' before '/'

c:\users\craig dickson\appdata\roaming\flexsim\flexsim16.2\compile\all.h(2372) : error C2008: '/' : unexpected in macro definition

c:\users\craig dickson\appdata\roaming\flexsim\flexsim16.2\compile\all.h(2373) : error C2143: syntax error : missing ';' before '/'

Choose One
visual studiocompile
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Vedant G avatar image Vedant G commented ·

What is the Make all code C++ supposed to do?

I don't see that option in 18.1.1

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Vedant G commented ·

That option changed each toggled node in the model from FlexScript to C++.

Starting with FlexSim 17.0, FlexScript is compiled and executed as machine code instead of interpreted bytecode. Also, we added new syntax to FlexScript that is no longer compatible with C++.

With those two new features starting in FlexSim 17.0, the option to "Make All Code C++" was removed because it is no longer useful.

2 Likes 2 ·
Jordan Johnson avatar image
2 Likes"
Jordan Johnson answered

Being familiar with your model, I tried compiling it myself. I will explain the issue in detail, but the result is that you should only switch the slowest or most important FlexScript nodes to C++, rather than the whole model.

However, if you are going for speed, I don't know if that will help very much. Rather, you should try to speed up the algorithm of your model. I know you are using the query command in your model. If you are using it for JOIN, WHERE, or ORDER BY on a big table (I saw one table with 20,000 rows in your model), and you are doing that often (say 100 or 1000 times during the model run), then that will be very slow. I noticed that you create 5,000 tokens at one point in the model. If each of those tokens queries (or does a search through the big table some other way), then that will be slow too.

You need to find the "hot path" for you model. I suggest running your model for a while, and then looking at the inputs of each activity, especially the custom code activities. Start with the node with the highest input, and see what the code is doing. Is it searching through a table? Is it using the query command? If so, find a way to do a one-time calculation at the beginning of your model; if you are joining tables, just join the tables at the beginning of the model, and dump the result. That way, every token won't join tables. Or if you are searching through a table for a particular row, try a different strategy to get to that node. I think you will find that improving the algorithm will have a far better effect on your model speed than toggling C++ and building the model.

The reason compiling the whole model doesn't work is because FlexSim generates a function name for each node toggled as C++. That name includes the node's path, which includes the names of its parent nodes. Your model exposes another bug, which is that FlexSim can't generate a function for a node with a comma in its path.

Unfortunately, your model has a lot of these. Every Text display in ProcessFlow has a FlexScript node on it, in case you choose to have the text be dynamic. If the text is not dynamic, this node is unused. However, the text usually displays it's own name. Many of those Text objects contain commas, which is tripping up the compiler. Rather than changing all your names to not have commas, I would find the nodes that matter, and make them C++.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Phil BoBo avatar image
1 Like"
Phil BoBo answered Phil BoBo edited

Try compiling the entire session in an empty model to see whether that works correctly first.

If that successfully compiles, then you can open your model and use the menu option Build > Open Visual Studio... to open Visual Studio where you can build the solution and jump straight to the code that is causing the errors.

If you can't figure out what is wrong, please post the model so that we can duplicate the issue to tell you what is happening.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.