| |||
| Home > Getting Started > Building an ISIM target > Overloading the main() function in the target | |||
The generated isim executable target has its own main() function.
To overload the default main() with a user-supplied main():
use the Project Settings dialog to define USER_DEFINED_ISIM_MAIN preprocessor option
for compiler as shown in Figure 2.22.
supply a C++ file or a library with user-defined main() function.
A fragment of the standard IsimMan.cpp file
is shown in Example 2.1for
comparison:
Example 2.1. Standard IsimMain()
#ifdef USER_DEFINED_ISIM_MAIN
// function that preforms command line parsing,
// CADI system initialization and run model
extern int LoadInitAndRunCADIModel(int argc, char *argv[]);
int main(int argc, char *argv[])
{
return LoadInitAndRunCADIModel(argc, argv);
}
#endif // #ifndef USER_DEFINED_ISIM_MAIN
The user-defined main() can implement
processing of own command line options but must, after filtering
out all user-defined switches, pass the remaining options to the
Model Shell entry function LoadInitAndRunCADIModel().
Add the new source file containing the custom main() to
the project. See Add Existing Files and Add New File
dialogs (Component window).
If the option USER_DEFINED_ISIM_MAIN and
a user-supplied main() are used, 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.