Independent modules

From ArachneWiki

Jump to: navigation, search

Independent modules are modules that you, the user, may write as additions to the Arachne code package. Arachne is designed so that it is easy to add these modules. See Compilation for information on how to design these modules for easy compilation.


Things to include

An executable module, by definition, must have a main() function. Arachne recognizes which modules are executable by searching for a line of code that begins:

int main(

This exact syntax is necessary; there must be no space before int, exactly one space between int and main, and no space between main and the opening parenthesis. (After this parenthesis may follow a space, or anything else.) If a module is executable, it should #include MainTools.h. It is also a good idea to call RunTime().

If your module accepts any command-line arguments, use the ParsedArgs module to handle them. In this case, running the module with no arguments will always produce an informative, automatically generated documentation of the command-line arguments needed. The arguments GDB and NO_HEADER are always accepted.

Useful features from the Arachne code package


We have static asserts available, which are checked at compile time. See StaticAssert.h. We also have many flavors of dynamic asserts; see Assert.h. In summary:

  • AssertXX() will test unless NDEBUG is set
  • ForceAssertXX() will always test, and moreover prevents inlining: use with caution in often called methods!
  • #define FAST_ASSERT allows inlining of ForceAsserts.


Include the following macros at the very top of your files. This turns off Asserts (Assert, AssertLt, AssertEq, etc), allowing methods that contain them, such as vec::operator[], to be inlined. ForceAsserts are not affected by this.

#define NDEBUG

If your code does a lot of work with strings, particularly comparisons and operator[], this will allow many of these operations to be inlined.


Data structures

Arachne contains many useful data structures, including souped-up versions of the C++ Standard Template Library modules. These modules include vec, String, Bool, and Equiv.


We have some typedefs that are used throughout the code (defined in Types.h):


An unsigned char with two archetypal constants: True (1) and False (0). The motivation for Bool is that the size of the built-in type bool varies from platform to platform, and can be as large as 64 bits, while Bool is always an unsigned char, i.e. one byte.


The built-in type long can vary in size from platform to platform; longlong is always 64 bits.

Other useful modules

Personal tools