Spin2Cpp easiest way to embed files?
Rayman
Posts: 14,665
One thing that I often do in Spin is embed files into the code.
This is pretty easy with the "file" command.
Don't see anything like this in PropGcc and there's no resource editor like in Visual Studio.
One thing I think can be done easily though is to create a Spin file with the files embedded in it
and then do Spin2Cpp and then compile that file too.
Is this a good approach?
Is there a better way?
This is pretty easy with the "file" command.
Don't see anything like this in PropGcc and there's no resource editor like in Visual Studio.
One thing I think can be done easily though is to create a Spin file with the files embedded in it
and then do Spin2Cpp and then compile that file too.
Is this a good approach?
Is there a better way?
Comments
Ray I've never used "resources" in visual studio. Do you reference them as variables?
Maybe this all only applies to MFC programming, but that's all I do, usually...
Note for Jazzed...
Resources on Windows and Mac OS are data accessible by running apps and the OS. They get bundled into the application's "package". Newer versions of the OS's have made most resources less-visible outside of the IDE, but they do exist. Icon files, plists, config files, etc. can all be included in the app package. On Mac OS X, they are visible by Control-clicking on an App's icon and selecting "Show Package COntents". I'm not sure how you get to them on Windows.
Even SimpleIDE has resources (at least on Mac OS X):
Ray, so your idea of pulling them into a Spin file should work. The files will be turned into 8-bit dat arrays (I think)...
dgately
spin2cpp created the following example of including a file in a DAT section of a .spin file...
Of course, a large file will create an expansive byte array, which you could move to a separate source file, right?
dgately
I was thinking of a spin file with an indexed list of embedded files.
There would also be one function that would return the address to a file, given it's index.
That's as much as I've thought about it...
Gotta finish up my current todo list, and get that other thing started....
That will wrap your file up in elf format and provide a label for your code to access it with.
Here is a nice atricle explaining how to do it:
http://balau82.wordpress.com/2012/02/19/linking-a-binary-blob-with-gcc/
Not sure if you can use this technique with spin2cpp but it's worth knowing.
to include an external data file. Data file was in text format though.
Still, could do Spin2cpp on a binary file and then include it this way...