Previous Topic Next topic Print topic


To create a C header file

Restriction: This topic applies to Windows environments only.

In C, a header file declares constants, functions and structures. The header file can be referenced (using the #include statement) by many programs. When the Declaration Generator creates a declaration for a C program, it writes the declaration to a header file (.h file). It also generates a corresponding array of short data types to hold the null-indicator variable for each column in the table.

To create a C header file, start the Declaration Generator utility, then follow the steps below:

  1. In the Language group box, click the C button.
  2. In the Table group box, select the Location, AuthID and Table that identifies the table for which you want to create a header file.
  3. If you want to change the name of the file to which the header file is written, type a new name in the Output File field (the Declaration Generator automatically places a default name based on the table name in this field).

    If you don't specify a path, the header file is written to the directory specified by the current application path (the application path is specified in the PATHS tab in Options).

    If you specify a file that already exists, you are given the choice of appending to it or overwriting it at run time.

  4. If you want to change the name of the structure, type a new name in the Structure field.
  5. If you want to add a prefix to each element name, type it in the Field Prefix box. You can end the prefix with a special character such as an underscore (_) to set it off from the rest of the name. For example, if a prefix of emp_ were specified, element names would be written as follows:
    char emp_lname[15]; 
    		char emp_fname[10]; 
    		char emp_dept[12]; 
    		.
    		. 
    		.

    Remember to take into account C variable-naming guidelines when assigning a prefix. Do not assign one containing characters that are disallowed by the compiler or one that might make the variable name too long.

  6. If you want to assign numbers instead of field names as element names, check the Numbered option. (This option can be selected only when a field prefix is used. See the previous step.) If the Numbered option were checked in the example above, the declaration would be written as follows:
    char emp_001[15]; 
    		char emp_002[10]; 
    		char emp_003[12]; 
    		.
    		. 
    		.
  7. Click the Options button.
  8. In the C Declaration Options dialog box, specify the way in which you want the structure written.
    • Use the options in the Structure Elements box to specify the case in which you want the element names written.
    • Use the Declare The Structure option to assign a variable name to the structure as shown in the following example. The variable name is derived from the Structure field specified in step 4).
      .
      		.
      		. 
      		double emp_payrate; 
      		double emp_com; 
      		} dcl_employee; 

    If you don't set Declare The Structure, the structure is written as a data-type definition. The name specified in the Structure field is assigned as the name of the data type, as shown in the following:

    struct dcl_employee 
    		{ 
    		short emp_ssn; 
    		char emp_lname[11];
    		char emp_fname[11]; 
    		.
    		. 
    		.
  9. If you want to save your specifications, click the Save As button, specify a file name and click OK. The specifications will be saved to a .DGE file, which can be used as input to the Declaration Generator batch mode. See Running in Batch Mode for more information about .DGE files and batch mode.
  10. Click the Generate button to generate the C header file.
Previous Topic Next topic Print topic