OpenersNotesSection(Spacer1)Details

The WSTP revision number and the WSTP API revision number should be set to the constants WSREVISION and WSAPIREVISION from (RefLink[wstp.h, paclet:ref/file/wstp.h]).

WSNewParameters() allocates memory for the (NonWLLink[WSEnvironmentParameter, paclet:ref/c/WSEnvironmentParameter]) object that must be released. Call (NonWLLink[WSReleaseParameters(), paclet:ref/c/WSReleaseParameters]) to release the memory allocated by WSNewParameters().

WSNewParameters() returns NULL if an error occurs.

WSNewParameters() 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 <stdlib.h>
#include "wstp.h"

/* initialize the WSTP environment */

WSENV f(void)
{
	WSENV env;
	WSEnvironmentParameter p;
	unsigned long res;

	p = WSNewParameters(WSREVISION, WSAPIREVISION);
	if(p == (WSEnvironmentParameter)0)
	{ /* Unable to initialize parameter object */ }

	WSSetAllocParameter(p, malloc, free);

	env = WSInitialize(p);
	if(env == (WSENV)0)
	{ /* Unable to initialize the WSTP environment */ }

	WSReleaseParameters(p);

	return env;
}

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

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(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])}})}})