github.com/gotranspile/cxgo@v0.3.7/libs/assert.go (about)

     1  package libs
     2  
     3  import (
     4  	"github.com/gotranspile/cxgo/types"
     5  )
     6  
     7  // https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/assert.h.html
     8  // https://pubs.opengroup.org/onlinepubs/9699919799/functions/assert.html
     9  
    10  const (
    11  	assertH = "assert.h"
    12  )
    13  
    14  func init() {
    15  	RegisterLibrary(assertH, func(c *Env) *Library {
    16  		strT := c.C().String()
    17  		l := &Library{
    18  			Imports: map[string]string{
    19  				"libc": RuntimeLibc,
    20  			},
    21  			Header: `
    22  #include <` + stdboolH + `>
    23  #define static_assert(x, y) /* x, y */
    24  `,
    25  			Idents: map[string]*types.Ident{
    26  				"_Static_assert": c.NewIdent("_Static_assert", "libc.StaticAssert", staticAssert, c.FuncTT(nil, types.BoolT(), strT)),
    27  			},
    28  		}
    29  		l.Declare(c.C().AssertFunc())
    30  		return l
    31  	})
    32  }
    33  
    34  func staticAssert(_ bool, _ *byte) {}