Shop OBEX P1 Docs P2 Docs Learn Events
PASM-style header file — Parallax Forums

PASM-style header file

I've looked high and low for an answer to this, but haven't found anything definitive (potentially using the wrong keywords).

I have multiple .spin object files which use the same set of constants.

If I need to change a constant for a test or other iteration, I have to manually edit the constant section of each file.

Is there a way to have a single file with a `CON` section that could be used by all other files?

I'm aware of the `FILE` PASM functionality, however using it seems overkill.

Comments

  • Yes. Create a file with your constants and a dummy method and treat it like an object. Then you can do this:
      someValue := myObject#SOME_CONSTANT
    
  • Another option is to use openspin, fastspin, or bstc and use #include to include a file literally. This won't work with the Propeller Tool though, only newer compilers.
    e.g.
    '' this is file common.spinh
    '' common CON for all files
    CON
      myone = 1
      mytwo = 2
      MyDefaultArrayLen = 10
    
    then use it like:
    #include "common.spinh"
    
    VAR
       long array[MyDefaultArrayLen]
    
  • ersmith wrote: »
    Another option is to use openspin, fastspin, or bstc and use #include to include a file literally. This won't work with the Propeller Tool though, only newer compilers.
    e.g.
    '' this is file common.spinh
    '' common CON for all files
    CON
      myone = 1
      mytwo = 2
      MyDefaultArrayLen = 10
    
    then use it like:
    #include "common.spinh"
    
    VAR
       long array[MyDefaultArrayLen]
    

    Thank you and @jonnymac for your inputs!

    It's funny actually, I came really close to jonny's solution but ran into the "at least one pub method required" build error. I assumed at that point my solution was a bad one.

    I like to hear more modern compilers exist. The project I'm working on is intended for people to exhert as little effort as humanly possible to use, so I'll dissuade from 3rd party compilers. However, I'll 100% be considering them for future projects.
Sign In or Register to comment.