Generate macros for public scalar consts

This commit is contained in:
Nigel Tao committed 2019-02-02 16:17:10 +11:00
1 parent 4af1b88ef8
commit 5f7c807729
5 files changed
+19 -3

No files matched your search

+6
View File
@@ -681,6 +681,12 @@ func (g *gen) gatherScalarConsts(b *buffer, n *a.Const) error {
}
func (g *gen) writeConst(b *buffer, n *a.Const) error {
if n.Public() {
if cv := n.Value().ConstValue(); cv != nil {
b.printf("#define %s %v\n\n", strings.ToUpper(g.pkgPrefix+n.QID()[1].Str(g.tm)), cv)
}
}
b.writes("static const ")
if err := g.writeCTypeName(b, n.XType(), "//\n"+g.pkgPrefix, n.QID()[1].Str(g.tm)); err != nil {
return err