From 03afd0afa2ee5e2e3995fb6385e1d33a783dd602 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 6 May 2017 15:29:18 -0700 Subject: csource: strip __STDC_VERSION__ macro from generated source --- csource/csource.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'csource/csource.go') diff --git a/csource/csource.go b/csource/csource.go index 4311bfc98..1bf3fc7a1 100644 --- a/csource/csource.go +++ b/csource/csource.go @@ -303,7 +303,6 @@ func preprocessCommonHeader(opts Options, handled map[string]int) (string, error } remove := append(defines, []string{ "__STDC__", - "__STDC_VERSION__", "__STDC_HOSTED__", "__STDC_UTF_16__", "__STDC_UTF_32__", @@ -312,6 +311,18 @@ func preprocessCommonHeader(opts Options, handled map[string]int) (string, error for _, def := range remove { out = strings.Replace(out, "#define "+def+" 1\n", "", -1) } + // strip: #define __STDC_VERSION__ 201112L + for _, def := range []string{"__STDC_VERSION__"} { + pos := strings.Index(out, "#define "+def) + if pos == -1 { + continue + } + end := strings.IndexByte(out[pos:], '\n') + if end == -1 { + continue + } + out = strings.Replace(out, out[pos:end+1], "", -1) + } return out, nil } -- cgit mrf-deployment