[Prev][Next][Index][Thread]

Re: Function pointers



Nolan Darilek <nolan_d@bigfoot.com> writes:

> Am I on the right track with this? If so, would anyone mind tossing
> out an example?

Here is an example where I wanted to make a 'system' type call from
Dylan callable from 'C' ('system' being a function that executes an
external program).

define method dylan-system(command) => ()
  run-application(command, 
                  inherit-console?: #f, 
                  under-shell?: #t, 
                  activate?: #t);
end method dylan-system;

define c-callable-wrapper of dylan-system
  parameter command :: <c-string>;
  export: #t;
  c-modifiers: "__stdcall";
  c-name: "dylan_system";
end;

This exports the 'dylan_system' function which can be called from 'C'
programs:

void dylan_system(char* command);

void a_func()
{
  dylan_system("some_app.exe");
}

Chris.
-- 
http://www.double.co.nz/dylan