Skip to content

Runtime source dependencies

Doug Binks edited this page Nov 18, 2020 · 6 revisions

Sometimes it's easier to add a source file dependency that create a library to use from RCC++. A runtime source dependency can be specified by using the following in a header:

#include "RuntimeSourceDependency.h"
RUNTIME_COMPILER_SOURCEDEPENDENCY;

This will cause compilation of the source file with the same name as the header file, but with the extension .cpp. Thus if the header with the above code in is called "myheader.h" the source file "myheader.cpp" will be compiled alongside any runtime modifiable code. We hope in future to add more general situations.

Note that this is not needed for source files which have a runtime modifiable class, as these are tracked via the REGISTERCLASS or REGISTERSINGLETON macros.

If the header is also a Runtime modifiable header files then the source code will be tracked for changes, causing a compilation of any dependent runtime modifiable code. This is useful when you need to add runtime modifiable code which does not fit well with using Runtime Modifiable Classes, however the programmer needs to maintain any state between compiles. In order for this to work the RUNTIME_MODIFIABLE_INCLUDE macro must be placed first as:

#include "RuntimeInclude.h"
RUNTIME_MODIFIABLE_INCLUDE;

#include "RuntimeSourceDependency.h"
RUNTIME_COMPILER_SOURCEDEPENDENCY;

Two alternative versions of the macro exist for handling the case of a different extension, and a different file.

#include "RuntimeSourceDependency.h"
RUNTIME_COMPILER_SOURCEDEPENDENCY_EXT(".c");
RUNTIME_COMPILER_SOURCEDEPENDENCY_FILE("AnotherSourceFile",".cpp");