https://github.com/randomgamingdev/binheadergen
A simple 1 file program for loading binary files into a header file that gets compiled directly into the executable.
https://github.com/randomgamingdev/binheadergen
binary cpp cpp20 easy fast file header include includes input simple small
Last synced: 29 days ago
JSON representation
A simple 1 file program for loading binary files into a header file that gets compiled directly into the executable.
- Host: GitHub
- URL: https://github.com/randomgamingdev/binheadergen
- Owner: RandomGamingDev
- License: mit
- Created: 2023-05-24T00:47:41.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-24T01:04:04.000Z (over 2 years ago)
- Last Synced: 2025-03-13T15:41:50.183Z (11 months ago)
- Topics: binary, cpp, cpp20, easy, fast, file, header, include, includes, input, simple, small
- Language: C++
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BinHeaderGen
A simple 1 file program for loading binary files into a header file that gets compiled directly into the executable.
These headers can be used for C/C++
In the header the binary data is stored in the form of a C-string/char*/char[] with each character representing a byte since C/C++ uses ASCII for characters which uses a byte for each character. This makes it not only easy for manipulation, but also really compacts since there's no need for things like commas inbetween, as it's just the pure binary data put inbetween 2 strings that turn it into a valid header.
Want to incorporate a file into your executable without a file?
Use this!
Simply compile using your favorite C++ 20 compiler (because it's just 1 file you can literally just use g++)
Then run the executable with a parameter like this: ./\ \
Then it'll generate `header.h` (remember to change the names and use namespaces wherever you want those)
Enjoy!
Storing data this way is perfect for:
- Avoiding file reading especially for systems where that may not be possible or for avoiding the inherent cost that comes with file reading
- Keeping things in a single executable
- Making sure that people don't actually break stuff by messing with files
- Making certain data harder to access