Embedding binary blobs using gcc mingw

In your C program remove the leading underscore:

#include <stdlib.h>
#include <stdio.h>

extern char binary_input_txt_start[];

int main (int argc, char *argv[])
{
    char *p;
    p = binary_input_txt_start;

    return 0;
}

C compilers often (always?) seem to prepend an underscore to extern names. I’m not entirely sure why that is – I assume that there’s some truth to this wikipedia article’s claim that

It was common practice for C compilers to prepend a leading underscore to all external scope program identifiers to avert clashes with contributions from runtime language support

But it strikes me that if underscores were prepended to all externs, then you’re not really partitioning the namespace very much. Anyway, that’s a question for another day, and the fact is that the underscores do get added.

Leave a Comment