This is a practical question. Could you write a program in C (or C ) that would save its entire source file text to a string/char array, to be used as needed? Not writing the code specifically to be a quine, but just output what already exists. Obviously this means your code's verbosity would end up determining the size of your string, but it could be useful in niche cases.
For example, I have made a standalone ad-hoc piece of lab equipment using an Arduino. I have included the paper hardware schematics in the box, but I would like to include the code itself too, so people going forward could modify and debug as needed.
The obvious answer is to print it to paper, but this means if I make a small change to the code, it would not be reflected, and they whoever works on it down the line would have to manually type it in, leaving room for mistakes.
I searched for something like this already and have come up dry. If I missed it, I apologize.
EDIT: I realize some of the constraints I am dealing with are not mentioned here.
Our organization does not allow flash drives or USB storage devices (blocked on computer level), so that is not an option unfortunately.
GitHub is another good option for this; I could simply put a permalink to the page inside. However, this means if someone finds it after I have left the company, they will have to fork it and start over if they want to modify.
A feature of this is that you would by definition always display the version of the code that the device is running, rather than having to guess.
Again, this is an application with an Arduino driving the functions; the only potential digital output from the hardware itself is plaintext through the serial. It even already has a USB port on it.
CodePudding user response:
I would create a repository on github or gitlab or similar free repository hosting service with your source.
You can easily include the URL in the source and even include git describe
as version string in the binary. You can create a QR code with the repository URL and print that on a piece of paper. If you have anything with a display you can print the QR code there too.
CodePudding user response:
I have made a standalone ad-hoc piece of lab equipment using an Arduino. I have included the paper hardware schematics in the box, but I would like to include the code itself too, so people going forward could modify and debug as needed.
Concatenate (zip or tar and gzip) all your source files in a known format and then just embed the result in the executable. Implement a printing function that would print the data to the user in documented format. Work on a good build-system that will automate the process of packaging source files.