Best way to embed data in source code?
I have a program that reads about 10K of data. This data will never change. It's all constants, etc.
So it seems I have these options:
- I could just include a ".dat" or ".txt" file with the program, in either binary or text format and have the program read and parse as part of its startup.
- I could unroll it all in the source code and have a subroutine that is simply thousands of "somevar[14] = 1.2;", etc. assignment lines. (Obviously, I could collapse arrays down to a single assignment, but you get my idea).
- Or...is there a way to embed the data in the source some other way? I'm thinking of a mechanism like perl's __DATA__.
I suspect it's either external .dat/.txt or lots of assignment lines, but I thought I'd ask if there are other techniques people use...?