-2

I have the following cgo arguments and I want to annotate lines with things like // this checks for 32bit etc. how can I do that without getting? invalid flag in #cgo CFLAGS: //

// #cgo CFLAGS: -I./depend/ -I./depend/src/
// #cgo 386 amd64p32 arm armbe mips mipsle mips64p32 mips64p32le ppc s390 sparc CFLAGS: -D32bit=1 // 32 bit
// #cgo amd64 arm64 arm64be ppc64 ppc64le mips64 mips64le s390x sparc64 CFLAGS: -D64bit=1 // 64 bit
// #cgo arm64be armbe mips mips64 mips64p32 ppc s390 s390x sparc sparc64 CFLAGS: -DBIGENDIAN=1 // big endian
// #include "example.c"
import "C"
elichai2
  • 1,365
  • 3
  • 14
  • 28
  • 1
    What have you tried? The preamble is parsed as C, so c-style comments should work correctly. – JimB Dec 09 '19 at 16:33
  • I tried just adding `// my comment` and I get `invalid flag in #cgo CFLAGS: //` – elichai2 Dec 09 '19 at 16:44
  • Please show the _exact_ source you are using. Since the comment is what is being process, you need to comment the text twice (or use c-style block comments for one level to make it more obvious). – JimB Dec 09 '19 at 16:47
  • @JimB Edited with the *exact* comment – elichai2 Dec 09 '19 at 17:53
  • `#cgo` directives (as well as others directives) are not C source, you can't put C comments on the same line. (not to mention, go style guidelines prefer comments to precede their subjects anyway) – JimB Dec 09 '19 at 17:58

1 Answers1

1

Try that:

// // comment in the comment
// #cgo CFLAGS: -I./depend/ -I./depend/src/
// // 32 bit
// #cgo 386 amd64p32 arm armbe mips mipsle mips64p32 mips64p32le ppc s390 sparc CFLAGS: -D32bit=1
// // 64 bit
// #cgo amd64 arm64 arm64be ppc64 ppc64le mips64 mips64le s390x sparc64 CFLAGS: -D64bit=1
// // big endian
// #cgo arm64be armbe mips mips64 mips64p32 ppc s390 s390x sparc sparc64 CFLAGS: -DBIGENDIAN=1
// #include "example.c"
import "C"
Nikifor
  • 211
  • 1
  • 4