Advantages of object files include:
- Because object files are ready to run, they do not need to be recompiled if the source file has not changed. This can save
you a lot of time. If your object file is more recent than your source file, the source file does not need to be recompiled
each time the file is first opened in a session; the object file is used as is.
- You can distribute object files without having to distribute the source equivalents. So if you have built some tests and
include files that you want to distribute but don’t want others to see the sources, you can distribute only the object files.
Since an object file cannot be run directly:
- Define the code you want to "hide" in an include file, which will be compiled into an
.ino object file.
- Call those functions from an ordinary script file.
- Distribute the
.t script file and the compiled
.ino include file. Users can open and run the script file as usual, through
.
Here’s a simple example of how you might distribute object files so that others cannot see the code.
In file
test.inc, place the definition of a function called
TestFunction. When you save the file, the entire include file is compiled into
test.ino.
TestFunction ()
ListPrint (Desktop.GetActive ())
In the file
test.t use the
test.inc include file.
Silk Test Classic will load the
.ino equivalent. Call
TestFunction, which was defined in the include file.
use "test.inc"
main ()
TestFunction () // call the function
Distribute
test.t and
test.ino. Users can open
test.t and run it but do not have access to the actual routine, which resides only in compiled form in
test.ino.