2.11.2 Overloading the main() function in the target

How to replace the default main() of the ISIM with a user-supplied main().


If you use the option USER_DEFINED_ISIM_MAIN and a user-supplied main(), you cannot build a CADI shared library from the project. If a CADI shared library is required:
  • Add a new configuration for isim_system that defines USER_DEFINED_MAIN.
  • Add an #ifdef USER_DEFINED_MAIN test block around the main() in the user source file.


  1. Define the USER_DEFINED_ISIM_MAIN preprocessor option for compiler with the Project Settings dialog.
    Figure 2-23 Specifying user-defined main() option
    Specifying user-defined main() option

  2. Supply a C++ file or a library with user-defined main() function.
    A fragment of the standard IsimMain.cpp file:
    #ifdef USER_DEFINED_ISIM_MAIN    // opposite logic to standard IsimMain.cpp
    #include "SimGenTplMacros.h"
    // function that performs command line parsing
    // CADI system initialization and run
    extern int LoadInitAndRunCADIModel(int argc, char *argv[],
                                       const char* topComponent,
                                       const char* pvLibVersion);
    int main(int argc, char *argv[])
        return LoadInitAndRunCADIModel(argc, argv, SIMGEN_TOP_COMPONENT,
    #endif // #ifdef  USER_DEFINED_ISIM_MAIN
    You might define the USER_DEFINED_ISIM_MAIN preprocessor option, for example, so that you can implement processing of your own command line options but must, after filtering out all user-defined switches, pass the remaining options to the Model Shell entry function LoadInitAndRunCADIModel().
  3. Add the new source file containing the custom main() to the project.
Related reference
4.3 Add Existing Files and Add New File dialogs (Component window)
Non-ConfidentialPDF file icon PDF versionARM DUI0370S
Copyright © 2007-2014 ARM. All rights reserved.