Shop OBEX P1 Docs P2 Docs Learn Events
Combining Spin and C[++] — Parallax Forums

Combining Spin and C[++]

DavidZemonDavidZemon Posts: 2,973
edited 2015-10-25 15:34 in Propeller 1
What are all the different ways that you can program a propeller with Spin and C/C++? I currently know of the following
  • Spin only (compiled to native byte code, via openspin)
  • Spin only (translated via spin2cpp and compiled via PropGCC)
  • C/C++ only (compiled via PropGCC)
  • C/C++ main function calling extracted binary from a Spin file (via spin2cpp w/ --dat option)
  • C/C++ main function calling c-wrapper functions (from spinwrap) from Spin file (compiled via openspin [or spin2cpp])
  • Spin extracted from C (translated via cspin and compiled with openspin)
What else? Anything else?

I'd like to find some way to integrate all of these options into PropWare, but I need to know what those options are first.

PropWare's support of various Spin options is documented in this GitHub issue.

Comments

  • DavidZemonDavidZemon Posts: 2,973
    edited 2014-09-25 19:11
    Related question: spin2cpp's "--binary" option will compile a Spin program for native execution right? how does it handle object imports (as in, what paths does it look through and how can those paths be explicitly defined)?
  • ersmithersmith Posts: 6,053
    edited 2014-09-26 06:01
    What are all the different ways that you can program a propeller with Spin and C/C++? I currently know of the following
    • Spin only
    • C/C++ only
    • C/C++ main function calling extracted binary from a Spin file (via spin2cpp w/ --dat option)
    • C/C++ main function calling extracted complete Spin file (via spin2cpp w/ no options)
    What else?
    spin2cpp --binary can also be used to just compile the Spin file to LMM or XMM code (or even COG code, if it will fit). All the Spin files referenced by the main one have to be in the same directory, or have paths given relative to the directory of the main Spin file (there isn't any INCLUDE path handling in spin2cpp yet).

    Eric
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-09-26 06:25
    Another option is SpinWrap.
  • David BetzDavid Betz Posts: 14,516
    edited 2014-09-26 06:28
    Dave Hein wrote: »
    Another option is SpinWrap.
    SpinWrap doesn't convert Spin to C or C++. It just provides a way to link native Spin/PASM code with C or C++ code. In other words, it provides a way to call native Spin objects from within a C or C++ program.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2014-09-26 06:54
    David Betz wrote: »
    SpinWrap doesn't convert Spin to C or C++. It just provides a way to link native Spin/PASM code with C or C++ code. In other words, it provides a way to call native Spin objects from within a C or C++ program.

    That's exactly what I'm looking for! Thank you :)

    I'm looking at any combination of Spin and C/C++. I'd like to find some way for PropWare to be a one-stop-shop for building your Propeller application.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2014-09-26 07:08
    Okay, I've added spinwrap and openspin to the first post.

    Far as I know, theres no way to convert C/C++ to Spin. Someone can correct me if I'm wrong.

    There are ways of calling C/C++ functions from Spin though. My very limited knowledge knows of at least PropForth. Presumably those files are compiled with PropGCC into object files... and then how are they combined into the executable and placed on the board for execution? What other ways can a program written in Spin (and PASM) call C/C++ functions?
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-09-26 09:17
    cspin will convert C to Spin, but it doesn't handle C++. It does have a few limitations, which are listed in the readme file. cspin relies on the clib and clibsd objects to provide C library functions that are written in Spin. These objects are included with cspin.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2014-09-26 10:56
    Dave Hein wrote: »
    cspin will convert C to Spin, but it doesn't handle C++. It does have a few limitations, which are listed in the readme file. cspin relies on the clib and clibsd objects to provide C library functions that are written in Spin. These objects are included with cspin.

    very cool!

    I think, even if I were never to integrate these options into PropWare, this thread can be a great resource for anyone playing with the Propeller :)
Sign In or Register to comment.