aboutsummaryrefslogtreecommitdiffstats
path: root/csource/csource.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-05-06 15:29:18 -0700
committerDmitry Vyukov <dvyukov@google.com>2017-05-06 15:29:18 -0700
commit03afd0afa2ee5e2e3995fb6385e1d33a783dd602 (patch)
treed5589f31b5d5ae19da9ec75b3d5e0f9e8fb6f9a4 /csource/csource.go
parent6b3319f489c9b5c7c5c3f4e04cc3a8897f634725 (diff)
csource: strip __STDC_VERSION__ macro from generated source
Diffstat (limited to 'csource/csource.go')
-rw-r--r--csource/csource.go13
1 files changed, 12 insertions, 1 deletions
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
}