On Tue, Aug 29, 2017 at 2:24 PM, Adrian Sampaleanu <nman...@gmail.com> wrote: > > I'm on Windows 10, 64 bit, with MinGW's gcc 7.2.0. The code I pasted isn't > relevant - I just pasted the first example from the Go blog, on cgo, as a > sanity check. I've now checked the "stdio" cgo sample that ships with the Go > distribution and that works fine.
Is it possible that on the version of GCC you are using with MinGW that <stdlib.h> does not declare random and srandom? Ian > On Tuesday, August 29, 2017 at 5:09:50 PM UTC-4, Ian Lance Taylor wrote: >> >> On Tue, Aug 29, 2017 at 1:24 PM, Adrian Sampaleanu <nma...@gmail.com> >> wrote: >> > >> > When running "go build" on the following code: >> > >> > package main >> > >> > // #include <stdlib.h> >> > import "C" >> > >> > func Random() int { >> > return int(C.random()) >> > } >> > >> > func Seed(i int) { >> > C.srandom(C.uint(i)) >> > } >> > >> > func main() { >> > } >> > >> > >> > I get this output: >> > .\main.go:7:13: could not determine kind of name for C.random >> > .\main.go:11:2: could not determine kind of name for C.srandom >> > >> > Having never used cgo before, I'm not sure if I'm doing something wrong, >> > but >> > I don't see the problem. Am I hitting this >> > (https://github.com/golang/go/issues/21668) ? >> >> I doubt this is issue 21668, which is specific to certain names. I'm >> not sure what the problem is. Your test case works for me. What >> system are you running on? What is your C compiler? >> >> (Note that you can use the math/rand package to get pseudo-random >> numbers, no need to use cgo for that.) >> >> Ian > > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.