I have a lib, that uses some C on linux. On windows it is just a dummy noop lib with functions that do nothing.
The lib is in 3 files: lib_linux.go
, lib_win.go
and lib.c
But when I try to compile it on windows, it throws this error: C source files not allowed when not using cgo or SWIG: lib.c
How can I tell to the go compiler to ignore the C source files on windows?
CodePudding user response:
A similar issue suggests (when tailored to your case):
workarounds
- Rename the
.c
file lib_linux.c;- Or add a build constraint
// build linux
condition to the top of the.c
file (conditional compilation).