"#include" files under SPIN
Alex.Stanfield
Posts: 198
Is there a statement to get CON sections included from an external file? (like an #include directive under C/C++)
Problem is to get all modules of my project to use the same constant definitions in order to minimize chances of different definitions during the several iterations/unit testing of different modules.
The most I could imagine is to build an object for all my definitions and then call them with the # connector, eg:
definition object
calling module(s)
but although it works it not as elegant as an #include and it wastes 3 longs for the null procedure (PropTool will not compile a module with no PUB routines)
Any ideas?
Alex
Problem is to get all modules of my project to use the same constant definitions in order to minimize chances of different definitions during the several iterations/unit testing of different modules.
The most I could imagine is to build an object for all my definitions and then call them with the # connector, eg:
definition object
'' PIN definition module (pins.spin) '' CON BUZZER = 6 PUB null
calling module(s)
OBJ PIN : "pins" PUB void beep(PIN#BUZZER)
but although it works it not as elegant as an #include and it wastes 3 longs for the null procedure (PropTool will not compile a module with no PUB routines)
Any ideas?
Alex
Comments
There is a "file" directive that can be used to load a DAT section.
If you are looking for use of #include (including data), there is a way of handling that at least (the "file" directive).
The open-source Spin compiler being developed (http://code.google.com/p/open-source-spin-compiler/) may (eventually) have pre-processing capability, and some of the other Spin compilers (like homespun) have some basic pre-processing directives.
1. Use Brad's bst or Mpark's homespun
2. Use Andy's PreSpin '' Compile with PropTool + "PreSpin 0.3" by Andy Schenk www.insonix.ch/propeller
'#include "__MODULE.spin" ' include the common code for OS modules
Warning: Don't forget the comment char ' at the start of the '#include comand!
I just downloaded the latest fix of bst but I couldn't find the #include directive in the manual and I couldn't get it to work by trying . Is there a way to use it?
I haven't tried PreSpin but from the description seems to be a one-file solution, does it work across nested objects?
Thanks to everyone for the comments.
Alex
The C pre-processor is perfectly good, well understood by most, well documented, thoroughly debugged, and open-source. It's relatively easy edits to handle comments that aren't //
So how do we use a C preprocessor (+ something else i guess) to compile a spin project?
Ok, granted it's a workable solution.
However a project wide pre-processor does look useful, BST has it along with some interesting features like eliminating unsed routines. Has anyone discovered if it has an equivalent form of #include ?
Alex
{comments may cause some issues, but worst would be to alter the comment before compilation and the compiler would not care}
' comments like BASIC are handled by a altered version I use for BASIC.
point me someplace that I can upload it, and it's yours, its GNU licensed anyway...