Product Documentation

Knowledgebase

Previous Topic

Next Topic

Prototyping

If your compiler supports function prototyping, we strongly suggest that you use this feature. A function declaration, or function prototype, establishes the name and return type of a function, as well as the types and number of arguments to the function. This information enables the compiler to check the types of the actual arguments when the function is used. If you accidentally use too few parameters when you invoke a prototype function, your compiler should give you a warning.

With some compilers it is very important that you use prototyping to avoid serious memory overwrites, for instance, with the Large memory model with the Microsoft C compiler, and functions that use TEXT pointers. If you do not include a function prototype in your code, the compiler will have to determine if it should use a 16-bit or 32-bit address for the function arguments. If it chooses the wrong one, the function may copy the information to the wrong location in memory. By including the function prototype in your code, you inform the compiler of the type of parameter that will be used, and the correct address will be passed.

The header file ctdecl.h contains declarations for the commonly used FairCom DB functions. There are two sets of declarations: one with prototypes and one without. By default, PROTOTYPE is defined in ctoptn.h. This will include the prototype definitions. If your compiler does not support prototyping, remove the PROTOTYPE define from ctoptn.h.

TOCIndex