external_define


Description

This function can be used to define an external function call to a specific dll (for Windows) or dylib (for Mac). This file can be either an included file or part of an extension. You supply the name (and path) of the file, then the name of the function that you wish to define. Next you need to define the calling convention to be used (see the constants list below) as well as the type of result to be expected (also a constant, as listed below). Finally you must give the number arguments that the function can take (from 0 to 15) and for each of the arguments you must specify its type too. Please note that for functions with 4 or more arguments, all of them must be of type ty_real.

NOTE: This is only for dll or dylib that have been added as "Included Files" to the GameMaker Studio 2 IDE. It will not work with those files added as extensions, since those require that you define the functions in the extension package itself.
Constant Description
dll_cdecl This is the default C, C++ call
dll_stdcall This is the standard WinAPI call (Windows dll only)
ty_real A real number argument
ty_string a null-terminated string argument


Syntax:

external_define(dll, name, calltype, restype, argnumb, argtype[0], argtype[1], ...argtype[10]) ;

Argument Description
dll The name of the dll file (string)
name The name of the function (string)
calltype The calling convention used
restype The type of the result to expect
argnumb The number of arguments (0 - 10)
argtype[0 ... 10] The different types of arguments being used


Returns:

Real (Unique function ID value)


Example:

my_funcion = external_define("MyDLL.dll", "MyMin", dll_cdecl, ty_real, 2, ty_real, ty_real);

The above example code will define an external function called "MyMin" with two arguments.