About
The macro MAXON_INITIALIZATION() is used to execute code when the application starts and when it shuts down. This is typically useful to allocate and free global data.
- Warning
- If the "init" functions of MAXON_INITIALIZATION() returns an error, all components defined in the current source file will not be loaded.
Usage
One can simply call global functions in the MAXON_INITIALIZATION() macro.
- Warning
- MAXON_INITIALIZATION() is called before the classic core is loaded. This means that classic API functions and classes (e.g. GePrint()) cannot be used in this context.
{
*g_machineName = data.Get(maxon::MACHINEINFO::COMPUTERNAME)
iferr_return;
}
static void ClearGlobalString()
{
if (g_machineName != nullptr)
}
static MAXON_METHOD DataDictionary GetMachineInfo()
Definition: string.h:1235
return OK
Definition: apibase.h:2690
#define MAXON_INITIALIZATION(...)
Definition: module.h:795
#define DeleteObj(obj)
Definition: newobj.h:159
#define NewObj(T,...)
Definition: newobj.h:108
#define iferr_scope
Definition: resultbase.h:1384
#define iferr_return
Definition: resultbase.h:1519
Or simply use a lambda within the macro itself:
{
*g_userName = data.Get(maxon::MACHINEINFO::USERNAME)
iferr_return;
},
[]()
{
});
If no function should be called nullptr can be set.
Further Reading