The Xc++ language allows for reflecting global variables
using $var
.
For example
$var+ string8 s;
The +
means that the global variable is public - so it is reflected and if it's
defined in a library then it is exported by the library.
For a windows dll __declspec(dllexport)
or __declspec(dllimport)
are
applied as required to both declarations and definitions of exported global variables.
When a $var
is reflected an instance of a
ReflectedGlobalVariable is registered in the
ReflectedGlobalVariable registry.
The following is a definition of a reflected global variable:
namespace ns
{
$var+ int32 x = 10;
}
A global variable must be defined only once. Therefore definitions of global variables appear in cpp files not header files.
Declarations of global variables in header files are qualified with extern
.
For example:
namespace ns
{
$var+ extern int32 x;
}