Variable modifiers Mixed-language calling conventions

C++Builder allows your programs to easily call routines written in other languages, and vice versa. When you mix languages , you have to deal with two important issues: identifiers and parameter passing.

By default, C++Builder saves all global identifiers in their original case (lower, upper, or mixed) with an underscore "_" prepended to the front of the identifier. To remove the default, you can use the -u command-line option.

he following table summarizes the effects of a modifier applied to a called function. For every modifier, the table shows the order in which the function parameters are pushed on the stack. Next, the table shows whether the calling program (the caller) or the called function (the callee) is responsible for popping the parameters off the stack. Finally, the table shows the effect on the name of a global function.

Calling conventions

Modifier Push parameters Pop parameters Name change (only in C)

__cdecl1 Right to left Caller '_' prepended
__fastcall Left to right Callee '@' prepended
__pascal Left to right Callee Uppercase
__stdcall Right to left Callee No change

1. This is the default.

Note: __fastcall and __stdcall are always name mangled in C++.


const ‘variable name’ [ = ‘value’ ] ;

‘function name’ ( const ‘type’*’variable name’ ;)

‘function name’ const;


Use the const modifier to make a variable value unmodifiable.

Use the const modifier to assign an initial value to a variable that cannot be changed by the program. Any future assignments to a const result in a compiler error.

A const pointer cannot be modified, though the object to which it points can be changed. Consider the following examples.

const float pi = 3.14;

const maxint = 12345; // When used by itself, const is equivalent to int.
char *const str1 = "Hello, world"; // A constant pointer

char const *str2 = "Borland International"; // A pointer to a constant character string.

Given these declarations, the following statements are illegal.

pi = 3.0; // Assigns a value to a const.

i = maxint++; // Increments a const.

str1 = "Hi, there!" // Points str1 to something else.


Popular posts from this blog

Password Remover

Advantages of the multi-tiered database model