OpenersNotesSection(Spacer1)Details

The WSTP environment object stores the global state of WSTP during the execution of a program.

A program can install custom memory allocators using the environment parameters object p.

An appropriate call to WSInitialize() is generated automatically when an external program is created from WSTP templates.

Any external program that uses the WSTP library must call WSInitialize() before calling any other link-related WSTP library functions.

The WSTP environment functions as a factory to create link objects.

WSInitialize() is declared in the WSTP header file (RefLink[wstp.h, paclet:ref/file/wstp.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "wstp.h"

int main(int argc, char **argv)
{
	WSENV ep;
	WSLINK lp;
	int error;

	ep = WSInitialize((WSEnvironmentParameter)0);
	if(ep == (WSENV)0)
		{ /* unable to initialize environment */ }

	lp = WSOpenArgcArgv(ep, argc, argv, &error);
	if(lp == (WSLINK)0 || error != WSEOK)
		{ /* unable to create link */ }

	/* ... */

	WSClose(lp);
	WSDeinitialize(ep);
	return 0;
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSNewParameters(), paclet:ref/c/WSNewParameters])  ▪  (NonWLLink[WSSetAllocParameter(), paclet:ref/c/WSSetAllocParameter])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Running the Wolfram System from within an External Program, paclet:tutorial/RunningTheWolframSystemFromWithinAnExternalProgram])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Mac OS X), paclet:tutorial/WSTPDeveloperGuide-MacintoshOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Unix and Linux), paclet:tutorial/WSTPDeveloperGuide-UnixOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Windows), paclet:tutorial/WSTPDeveloperGuide-WindowsOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Alphabetical Listing of WSTP C Functions, paclet:guide/AlphabeticalListingOfWSTPCFunctions])}, {▪(RefLinkPlain[WSTP C Language Functions, paclet:guide/WSTPCLanguageFunctions])}, {▪(RefLinkPlain[WSTP Connection Management, paclet:guide/WSTPConnectionManagement])}})}})