0

I have been trying to look for a way to store files as const char* at compile time.

I tried doing this:

#define STRINGIFY(...) #__VA_ARGS__ // va args deals with commas
#define INCLUDE(path) #include path // error: '#' is not followed by a macro parameter

constexpr const char* source = STRINGIFY(INCLUDE("source.txt"));

but unfortunately you can't place include directives inside a macro expansion. Is there any way around this problem? Or any other way to get the contents of a file at compile time?

MaximV
  • 155
  • 11
  • In particular, you appear to be looking for this [solution](https://stackoverflow.com/a/26161526/8372853). – cigien Jun 14 '20 at 21:47

1 Answers1

1

the classic way to do this is to write an awk or perl script that reads the data file and generates a .H file

pm100
  • 48,078
  • 23
  • 82
  • 145