On Fri, Jun 21, 2024 at 05:30:02PM +0200, Tobias Burnus wrote:
> gcc/ChangeLog:
>
> * config/gcn/mkoffload.cc (read_file): Remove.
> (process_obj): Generate C file that uses #embed.
> (main): Update call to it; remove no longer needed file I/O.
> + fprintf (cfile,
> + "static unsigned char gcn_code[] = {\n"
> + "#if defined(__STDC_EMBED_FOUND__) && __has_embed (\"%s\") ==
> __STDC_EMBED_FOUND__\n"
If this was an attempt to deal gracefully with no #embed support, then
the above would be wrong and should have been
#if defined(__STDC_EMBED_FOUND__) && defined(__has_embed)
#if __has_embed ("whatever") == __STDC_EMBED_FOUND__
or so, because in a compiler which will not support __has_embed
you'll get error like
error: missing binary operator before token "("
on
#if defined(__STDC_EMBED_FOUND__) && __has_embed ("whatever") ==
__STDC_EMBED_FOUND__
as it is handled like
#if 0 && 0 ("whatever") == 0
Now, if all you want is an error if the file doesn't exist, then
#embed "whatever"
will do that too (though, in the patchset currently posted that is
still a fatal error, rather than just a normal one, perhaps we should
change that).
If you want an error not just when it doesn't exist, but also when it
is empty, then you could do
#embed "whatever" if_empty (%%%)
(or whatever is syntactically not valid there).
Jakub