Darwin Help

Back to Index

CreateCProgram

Function CreateCProgram - create the skeleton of a Darwin function in C

Calling Sequence  CreateCProgram(p,name)
Parameters
NameTypeDescription

p procedurea Darwin function/procedure
name stringthe name given to the C program
Return Type  NULL
Synopsis Creates a file, named name.c, containing a skeleton C program corresponding to procedure p and prints to the terminal a procedure packaging the call to the external program.
Examples
> Increment := proc(x) x+1 end;
Increment := proc (x) x+1 end
> CreateCProgram(Increment,AddOne);
AddOne := proc (x)
  CallExternal ('AddOne', x)
end:
> CallSystem( 'cat AddOne.c' );
#include "extcalls.h"
#define MaxReturnSize 10000
#define MaxReturnArgs 1

main (int argc, char **argv)
{
  extref *x;

  extenter (argv[1], MaxReturnSize, MaxReturnArgs);
  x = extget (1);

  /* Here comes the actual C code */

  extexit ();
}


See also CallExternal