cgo.go 779 B

12345678910111213141516171819
  1. // SPDX-License-Identifier: Apache-2.0
  2. // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
  3. //go:build cgo && (darwin || freebsd || linux)
  4. package purego
  5. // if CGO_ENABLED=1 import the Cgo runtime to ensure that it is set up properly.
  6. // This is required since some frameworks need TLS setup the C way which Go doesn't do.
  7. // We currently don't support ios in fakecgo mode so force Cgo or fail
  8. // Even if CGO_ENABLED=1 the Cgo runtime is not imported unless `import "C"` is used.
  9. // which will import this package automatically. Normally this isn't an issue since it
  10. // usually isn't possible to call into C without using that import. However, with purego
  11. // it is since we don't use `import "C"`!
  12. import (
  13. _ "runtime/cgo"
  14. _ "github.com/ebitengine/purego/internal/cgo"
  15. )