What is difference between #embed and #include in C
11:47 19 Oct 2026

Does #embed insert a file as raw bytes, while #include inserts it as ASCII?

What exactly is the difference between the following two?

➜ /tmp cat hi.txt
"Hello World!\n"
"What's up bro?\n"

➜ /tmp cat main.c
#include 

int main() {
        char *A[] = {
                #include "hi.txt"
        };

        printf("%s", A[0]);
}

➜ /tmp gcc main.c ; ./a.out
Hello World!
What's up bro?

➜ /tmp

=========

Now:

➜ /tmp cat main.c
#include 

int main() {
        char *A[] = {
                #embed "hi.txt"
        };

        printf("%s", A[0]);
}

➜ /tmp gcc main.c ; ./a.out
main.c: In function ‘main’:
main.c:5:24: error: initialization of ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
    5 |                 #embed "hi.txt"
      |                        ^~~~~~~~
main.c:5:24: note: (near initialization for ‘A[0]’)
main.c:5:24: error: initialization of ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
main.c:5:24: note: (near initialization for ‘A[1]’)

Why does this produce an error?

Now, if the contents of hi.txt were something like the following:

.field1 = 10,
.field2 = 20,

why does #include include it in such a way that it becomes valid C syntax, while #embed does not?

Is the difference related to where and at what stage/layer the file contents are inserted into the translation process?

c include embed c23