Skip to content

Commit

Permalink
define __STDC macros from C23
Browse files Browse the repository at this point in the history
  • Loading branch information
wrongnull authored Jul 13, 2024
1 parent b61abd3 commit 7c7d5e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/aro/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,9 @@ pub fn generateBuiltinMacros(comp: *Compilation, system_defines_mode: SystemDefi
\\#define __STDC_NO_VLA__ 1
\\#define __STDC_UTF_16__ 1
\\#define __STDC_UTF_32__ 1
\\#define __STDC_EMBED_NOT_FOUND__ 0
\\#define __STDC_EMBED_FOUND__ 1
\\#define __STDC_EMBED_EMPTY__ 2
\\
);
if (comp.langopts.standard.StdCVersionMacro()) |stdc_version| {
Expand Down
8 changes: 4 additions & 4 deletions test/cases/#embed.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ const int bar =
;
_Static_assert(bar == 'H', "");

# if __has_embed("include/embed data" foo(1)) != 0
# if __has_embed("include/embed data" foo(1)) != __STDC_EMBED_NOT_FOUND__
#error unknown param was accepted
#endif

# if __has_embed("doesn't exist") != 0
# if __has_embed("doesn't exist") != __STDC_EMBED_NOT_FOUND__
#error non-existent embed found
#endif

# if __has_embed("include/embed data" limit(1)) != 1
# if __has_embed("include/embed data" limit(1)) != __STDC_EMBED_FOUND__
#error embed should be found
#endif

# if __has_embed("include/empty") != 2
# if __has_embed("include/empty") != __STDC_EMBED_EMPTY__
#error empty wasn't detected
#endif

Expand Down

0 comments on commit 7c7d5e1

Please sign in to comment.