Sometimes it is desirable to embed resource files in c or c++ programs. There are many ways to go about it but in most cases you must convert the files with external tools or scripts.
For image files, image-magick can be used:
$ imagick input.png output.h
Another common tool that can convert all types of files is xxd.
$ xxd -i input.whatever output.h
While the above methods are perfectly valid, some extra dependencies are added to the build process.
Using the preprocessor
One interesting way to do this for plain ascii files (eg. shaders) can be found in Bullet's MiniCL example programs and more specifically in lines 31-33 of MiniCL_VectorAdd.cpp
A preprocessor macro is defined and a string declaration is placed before the file inclusion directive.
[...] #define STRINGIFY(A) #A char *fsource = #include "file.ext" [...]
... continue reading