138
Pascal 4.0 User’s Guide
7
Compatibility of Types for C++ and Pascal
Table 6-1 and Table 6-2 on page 90 list the default sizes and alignments of
compatible types for C and Pascal. They apply to C++ as well.
C++ Name Encoding
To implement function overloading and type-safe linkage, the C++ compiler
normally appends type information to the function names. To prevent the C++
compiler from doing so, and to allow Pascal to call a C++ function, declare the
C++ function with the
extern "C"
language construct. One common way to
do this is in the declaration of a function, like this:
For brevity, you can also combine
extern "C
" with the definition of the
function, as in:
Procedure Calls: C++–Pascal
Following are examples that illustrate how a C++ main program calls a Pascal
procedure. Included in each example are the Pascal procedure, the C++ main
program, and the commands to compile and execute the final program.
extern "C" void f (int);
...
void f (int) { /* ...body of f... */ }
extern "C" void f (int)
{ /* ...body of f... */ }
The Pascal procedure,
Samp,
in the file,
Samp.p
procedure Samp (var i: integer; var r: real);
begin
i := 7;
r := 3.14;
end
Summary of Contents for SunSoft Pascal 4.0
Page 14: ...xiv Pascal 4 0 User s Guide ...
Page 16: ...xvi Pascal 4 0 User s Guide ...
Page 30: ...6 Pascal 4 0 User s Guide 1 ...
Page 160: ...136 Pascal 4 0 User s Guide 6 ...
Page 268: ...244 Pascal 4 0 User s Guide 11 ...
Page 320: ...296 Pascal 4 0 User s Guide B ...
Page 331: ...Index 307 ...
Page 333: ......