File: cfunc.yo

package info (click to toggle)
c%2B%2B-annotations 12.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 13,044 kB
  • sloc: cpp: 24,337; makefile: 1,517; ansic: 165; sh: 121; perl: 90
file content (28 lines) | stat: -rw-r--r-- 1,097 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Normal bf(C) functions, e.g., which are compiled and collected in a run-time
library, can also be used in bf(C++) programs. Such functions, however, must be
declared as bf(C) functions.

As an example, the following code fragment declares a function tt(xmalloc)
as a bf(C) function:
        verb(    extern "C" void *xmalloc(int size);)

This declaration is analogous to a declaration in bf(C), except that the
prototype is prefixed with ti(extern "C").

    A slightly different way to declare bf(C) functions is the following:
        verb(    extern "C"
    {
        // C-declarations go in here
    })

It is also possible to place preprocessor directives at the location of
the declarations. E.g., a bf(C) header file tt(myheader.h) which declares
bf(C) functions can be included in a bf(C++) source file as follows:
        verb(    extern "C"
    {
        #include <myheader.h>
    })

Although these two approaches may be used, they are actually seldom
encountered in bf(C++) sources. A more frequently used method to declare
external bf(C) functions is encountered in the next section.