WSMain (C Function)

sets up communication between an external program started using Install and the Wolfram Language.

Details

  • The code for WSMain() is generated automatically by mprep or mcc.
  • WSMain() opens a WSTP connection using the parameters specified in argv, then goes into a loop waiting for CallPacket objects to arrive from the Wolfram Language.
  • WSMain() internally calls WSOpenArgcArgv().
  • WSMain() is declared in the WSTP header file wstp.h.

Examples

Basic Examples  (1)

#include "wstp.h"

#if WINDOWS_MATHLINK

/* a Microsoft Windows example WinMain routine */

int PASCAL WinMain( HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, LPSTR lpszCmdLine, int nCmdShow)
{
char buff[512];
char FAR * buff_start = buff;
char FAR * argv[32];
char FAR * FAR * argv_end = argv + 32;

     hinstPrevious = hinstPrevious; /* suppress warning */

if( !WSInitializeIcon( hinstCurrent, nCmdShow)) return 1;
WSScanString( argv, &argv_end, &lpszCmdLine, &buff_start);
return WSMain( (int)(argv_end - argv), argv);
}

#else

int main(int argc, char* argv[])
{
return WSMain(argc, argv);
}

#endif