Show/Hide Toolbars

XSharp

Suppress generation of empty $Init1() and $Exit() functions

 

Background info

The X# compiler generates special functions in each assembly that are used to call INIT procedures and EXIT procedures.

There are 3 levels of INIT procedures.

For each of these 3 levels a special function is created: $Init1(), $Init2() and $Init3(). For EXIT procedures the compiler creates a function $Exit().

The functions $Init2() and $Init3() are only created when needed.

The functions $Init1() and $Exit() are always created.

 

When you compile an EXE with X# then the compiler generates code that calls the $Init1(), $Init2() and $Init3() functions in all referenced assemblies at startup and the $Exit() functions at shutdown.

 

This mechanism also guarantees that classes in referenced assemblies are available at runtime, even when you have not explicitly referenced them in your code, so you can instantiate these classes with CreateInstance().

 

The compiler option -noinit suppresses the generation of empty $Init1() and $Exit() functions. As a result there will be no hard link to external assemblies if you do not reference code from these assemblies.

If you use these compiler option with an assembly that only contains DEFINES then the defines will be resolved at compile time and you will not need to include the assembly at runtime (unless these defines contain values that need to be resolved at runtime, such as symbols or date values).