home *** CD-ROM | disk | FTP | other *** search
/ Freelog 22 / freelog 22.iso / Prog / Djgpp / GPC2952B.ZIP / lib / gcc-lib / djgpp / 2.952 / include / gpc-in-c.h
Encoding:
C/C++ Source or Header  |  2001-02-08  |  2.6 KB  |  74 lines

  1. /*
  2. Header to support the inclusion of GPC compiled code into C programs
  3.  
  4. Author: Frank Heckenbach <frank@pascal.gnu.de>
  5.  
  6. Released to the public domain.
  7. */
  8.  
  9. #ifndef __GPC_IN_C_H
  10. #define __GPC_IN_C_H
  11.  
  12. /*
  13.   If you want to call GPC compiled code from C programs where the C
  14.   code contains the `main' function, you need to call the following
  15.   Pascal routines from your C code.
  16.  
  17.   Furthermore, you have to tell GPC not to create a `main' function.
  18.   You do this with the command line option `--gpc-main=Dummy' to GPC
  19.   or the compiler directive `{$gpc-main=Dummy}' in the Pascal
  20.   program's source.
  21.  
  22.   GPC will then create a function called `Dummy' instead of `main'.
  23.   Don't call this function from your C code. It would call the three
  24.   routines mentioned here and the Pascal main program in a row (just
  25.   like `main' does in normal GPC compiled programs), and give you no
  26.   chance to do anything in between. If you call the three routines
  27.   explicitly, you can safely ignore `Dummy'. (You can choose any
  28.   other name instead of `Dummy' as long as it doesn't conflict with
  29.   your global C symbols.)
  30.  
  31.   For a complete example, see the demo program `gpc_c_pas.pas',
  32.   together with `gpc_c_unit.pas' and `gpc_c_c.c'.
  33. */
  34.  
  35. /*
  36.   _p_initialize() (part of GPC's Run Time System) must be called
  37.   before calling any routines written in Pascal, including the
  38.   Pascal initializers (see below), unless you know very well what
  39.   you're doing. The meaning of the parameters should be obvious to
  40.   any C programmer. envp can be omitted (i.e., passed as NULL) if
  41.   your system supports the `environ' variable. If you don't know if
  42.   it does, you can check HAVE_ENVIRON in p/rts/rts-config.h after
  43.   building GPC on your system.
  44. */
  45. extern void _p_initialize (int argc, char **argv, char **envp);
  46.  
  47. /*
  48.   If there is a Pascal program, init_pascal_main_program() is
  49.   generated by GPC. It initializes the main program's and all
  50.   units' and modules' variables, and runs all unit and module
  51.   initializers.
  52.  
  53.   If you have a unit or module called `foo' written in Pascal, you
  54.   can declare
  55.  
  56.   extern void init_Foo ();
  57.  
  58.   instead (note the case) and call it to initialize the variables
  59.   and run the constructors of the mentioned unit/module and all
  60.   units/modules used by it.
  61. */
  62. extern void init_pascal_main_program ();
  63.  
  64. /*
  65.   _p_finalize() (also part of GPC's Run Time System) should be
  66.   called at the end of the program to run all units' and modules'
  67.   finalizers and clean up the RTS (otherwise, e.g., some files might
  68.   not get flushed). After calling it, you should not call any
  69.   routines written in Pascal.
  70. */
  71. extern void _p_finalize ();
  72.  
  73. #endif
  74.