112855Sgabeblack@google.com#include "systemc.h" 212855Sgabeblack@google.com 312855Sgabeblack@google.comint main() 412855Sgabeblack@google.com{ 512855Sgabeblack@google.com char *argv[] = { strdup("0"), strdup("1"), strdup("2"), strdup("3"), 612855Sgabeblack@google.com strdup("4"), NULL }; 712855Sgabeblack@google.com int argc = sizeof argv / sizeof argv[0] - 1; 812855Sgabeblack@google.com sc_elab_and_sim( argc, argv ); 912855Sgabeblack@google.com for (int i = 0; i < argc; ++i) { 1012855Sgabeblack@google.com free(argv[i]); 1112855Sgabeblack@google.com } 1212855Sgabeblack@google.com} 1312855Sgabeblack@google.com 1412855Sgabeblack@google.comint sc_main(int argc, char* argv[]) 1512855Sgabeblack@google.com{ 1612855Sgabeblack@google.com // Number of arguments should be the same 1712855Sgabeblack@google.com sc_assert(argc == sc_argc()); 1812855Sgabeblack@google.com 1912855Sgabeblack@google.com // Ensure all arguments are the same as sc_argv 2012855Sgabeblack@google.com for ( int argi = 0; argi < argc; argi++ ) { 2112855Sgabeblack@google.com if ( strcmp( argv[argi], sc_argv()[argi] ) != 0 ) { 2212855Sgabeblack@google.com cout << "sc_argv()[" << argi << "] mismatch: expected: '" 2312855Sgabeblack@google.com << argv[argi] << "' got: '" << sc_argv()[argi] << "'" << endl; 2412855Sgabeblack@google.com } 2512855Sgabeblack@google.com } 2612855Sgabeblack@google.com 2712855Sgabeblack@google.com // This check will most likely not do anything since we are likely to have 2812855Sgabeblack@google.com // zeros on the stack, but let's add it anyway. 2912855Sgabeblack@google.com sc_assert(argv[argc] == NULL); 3012855Sgabeblack@google.com sc_assert(sc_argv()[argc] == NULL); 3112855Sgabeblack@google.com 3212855Sgabeblack@google.com // Ensure that modifying argv does not alter sc_argv 3312855Sgabeblack@google.com argv[1][0] = '9'; 3412855Sgabeblack@google.com free(argv[2]); 3512855Sgabeblack@google.com argv[2] = strdup("new-2"); 3612855Sgabeblack@google.com sc_assert(strcmp(sc_argv()[2], "2") == 0); 3712855Sgabeblack@google.com sc_assert(strcmp(sc_argv()[1], "1") == 0); 3812855Sgabeblack@google.com 3913158Sgabeblack@google.com cout << "Program completed" << endl; 4012855Sgabeblack@google.com 4112855Sgabeblack@google.com return 0; 4212855Sgabeblack@google.com} 43