Coolquest, Inc. Home Products Support About Contact
cbold_logo_gif C++BOLD Reference Manual cbold_logo_gif

<<< Previous CBOLD Reference Home Next >>>

 

5. The main() Function

The main() function is not actually a part of CBOLD. Unlike most of CBOLD, the source code in main() is intended to be directly modified by the designer to fit his needs. Furthermore, the main() function is located in a .cpp file in a design directory, not with the CBOLD source code. As described in the Creating a New Design section, the designer should obtain the source code for main() from an existing design, e.g., the skeleton design provided with the CBOLD framework source code.

Though main() is not technically a part of CBOLD, it must be correctly coded for all of the features of CBOLD to function properly. The general structure of main() is:

int main(int argc, char* argv[]) {
  try {                                      // code for normal execution
    CM_Root Root;                            // the root module of the user's design
 
            // ***** Processing required by CBOLD *****
    ...     // e.g., registering, connecting, assigning reference designators
 
            // ***** Optional Postprocessing *****
    ...     // e.g., outputting CAD netlists, bills of materials, etc.
  }
  catch ( string& aString ) {                // error handler
     ...
  }
  return 0;                                  // exit main()
}

If CBOLD detects an error, it throws an exception that contains an error string. Any processing in the try block is aborted, and execution resumes at the catch statement. The catch block typically generates an error message based on the error string, as illustrated in the example designs.

 

<<< Previous CBOLD Reference Home Next >>>

Legal Copyright © 2007 by Coolquest, Inc. Contact