Weekly Quiz number: 41 (2026)

Solve the quiz and collect tokens!

Type your nickname in the field below before submitting your solution. If you select the correct answer and submit it with your nick-name a token will be generated for you. Collect tokens and the corresponding nickname(s). If you get at least 10 of them you might be rewarded ;-)


Coding Quiz: #embed

Historically, it was hard to include binary data into C and C++ programs as the #include preprocessor directive requires the contents to be compatible with the C or C++ language. Solutions included converting the data in integer literals or complicated linker invocations.

#embed is a preprocessor directive for placing the contents of a binary resource directly into a C or C++ program. It was standardized in C23 and C++26. Instead of treating a file as source text, it produces integer values that can, for example, initialize an array.

constexpr unsigned char logo[] = {
#embed "logo.png" if_empty(0)
};

constexpr unsigned char random[] = {
#embed "/dev/urandom" limit(1024)
};

Question 1: The Main Benefit

What is the main benefit of #embed over classic #include when putting an image, firmware blob, or other binary resource into a program?

A: Stringification: It automatically converts every binary file to a null-terminated string.
B: Speed: It embeds binary data as integer values, avoiding the source-token and parsing overhead of generated C++ initializers.
C: Delay: It allows a program to read a file lazily from an internal virtual file system at runtime without using file I/O.
D: Magic: It detects the file format by its file extension and handles it appropriately.

Question 2: Eligible Files

What kind of files can be embedded with #embed?

A: Only image formats such as PNG, JPEG, and GIF.
B: Only text files encoded as UTF-8.
C: Any resource the implementation can process as a binary data sequence.
D: Only files that are valid C or C++ source code.

Question 3: Parameters

Which of the following is not a standard #embed parameter?

A: limit(256)
B: prefix(0xEF, 0xBB, 0xBF, )
C: if_empty(0)
D: encoding(UTF-8)

If you found these questions interesting, feel free to join the

Software Design Meeting

Shape the agenda of our Software Design Meeting! Submit topics that you would like to dive deeper into: Software Design Meeting: Topic Ideas Survey (https://bos.ch/vhzwinp)

The coaching team holds a software design meeting every Thursday. It is open to anyone looking to expand their knowledge and connect with like-minded peers. (To receive an invitation, please reach out to Milosz Walter (XC-AS/ESE4) or visit https://bos.ch/join-sw-design-meeting)

E-Mail Reminder

Want a quick email notification in your inbox when the next quiz is live? Visit https://bos.ch/coding-quiz-reminder

 

 


Make sure your nickname contains at least 8 characters and is a unique as possible.




Disclaimer: