Oracle® Solaris Studio 12.4: C User's Guide

Exit Print View

Updated: March 2015
 
 

6.1.2 Updating Existing Code

If you have an existing application and want the benefits of function prototypes, a number of possibilities for updating exist, depending on how much of the code you would like to change:

  1. Recompile without making any changes.

    Even with no coding changes, the compiler warns you about mismatches in parameter type and number when invoked with the– v option.

  2. Add function prototypes only to the headers.

    All calls to global functions are covered.

  3. Add function prototypes to the headers and start each source file with function prototypes for its local (static) functions.

    All calls to functions are covered, but this method requires typing the interface for each local function twice in the source file.

  4. Change all function declarations and definitions to use function prototypes.

For most programmers, choices 2 and 3 are probably the best cost/benefit compromise. Unfortunately, these options are precisely the ones that require detailed knowledge of the rules for mixing old and new styles.