home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / prolog / library / prolo_c / read64.me < prev    next >
Text File  |  1986-10-06  |  2KB  |  57 lines

  1. Sample programs 64 and 65, EXAMPLE64.PRO and EXAMPLE65.C, respectively,
  2. demonstrate how to access a subroutine written in C from a Turbo Prolog
  3. program.
  4.  
  5. Any C compiler that can compile large memory model can be used to
  6. compile C modules for use with Prolog.  However, any compiler that puts
  7. an '_' AFTER public identifiers (i.e. example becomes example_) cannot
  8. be used with Turbo Prolog.
  9.  
  10. Lattice C 2.15 and 3.0 were used to compile EXAMPL65.C to an .OBJ file.
  11.  
  12.    Note: Large memory models must be used when linking
  13.          modules to Turbo Prolog from any other language.
  14.  
  15. GENERAL NOTES
  16. -------------
  17.  
  18. Using the C compiler, version 2.15 issue the following commands:
  19.  
  20.    LC1 EXAMPL65 -mL -N -S -iC -b
  21.    LC2 EXAMPL65 -v
  22.  
  23. using the C compiler, version 3.0 issue the following command after
  24. reading the note below:
  25.  
  26.    LCL EXAMPLE65
  27.  
  28.    NOTE: Remove stack checking by adding the -v option to LCL.BAT.
  29.  
  30. The above compilation produces a new file: EXAMPL65.obj
  31.  
  32. Compile EXAMPL64.PRO to an OBJ file.  Use DOS LINK.EXE to link together
  33. the Prolog and C modules and create an .EXE file.  Below is an example
  34. of the link statement:
  35.  
  36.     link init exampl64 exampl65 exampl64.sym,first,,prolog
  37.  
  38. This results in the creation of FIRST.EXE.
  39.  
  40.  
  41. PARAMETER PASSING
  42. -----------------
  43.   Integers, characters and reals are passed on the stack by value.
  44.   Their corresponding data types in C are int, char and double
  45.   respectively.  Unbound variables are passed as pointers (i.e. an
  46.   unbound integer X would be called from C as int *X).
  47.  
  48.   Strings and symbols are passed as character pointers (ie. char
  49.   *string) to external routines.  An unbound string or symbol is passed
  50.   as a pointer to a pointer to character (ie. char **string).
  51.  
  52.   Functors and lists are passed as structures.  EXAMPL65.C is an
  53.   example of how functors and lists are passed to C.
  54.  
  55.   For more information on passing parameters to C see page 156 of the
  56.   manual.
  57.