gccgo

Using C(++) in a Go application for performance

丶灬走出姿态 提交于 2019-12-09 10:01:58
问题 I've started studying Go a couple of days ago and came by its CGO thing and the gccgo compiler. From my understanding this allows a Go program to compile using the Go compiler and compile C libraries using a C compiler and reference those libraries from inside a Go program. This is really interesting to me because this allows us to leverage C's performance (if needed) from our main program with little overhead. However I'm not sure how little that is, so I'm asking here: Are there cases where

integer division in Go called from C

烈酒焚心 提交于 2019-12-07 08:45:47
问题 I am able to perform integer division in go by this program : package main import "fmt" func main() { a := 10 b := 5 fmt.Println(a/b) } Then I made a program in go that has functions for +, -, * and /. and I made a program in C that calls each of these functions and performs arithmetic operations. Except division, the code works fine. The go file with the functions is : (calc.go) package main func Add(a, b int) int { return a + b } func Sub(a, b int) int { return a - b } func Mul(a, b int)

integer division in Go called from C

核能气质少年 提交于 2019-12-05 17:16:15
I am able to perform integer division in go by this program : package main import "fmt" func main() { a := 10 b := 5 fmt.Println(a/b) } Then I made a program in go that has functions for +, -, * and /. and I made a program in C that calls each of these functions and performs arithmetic operations. Except division, the code works fine. The go file with the functions is : (calc.go) package main func Add(a, b int) int { return a + b } func Sub(a, b int) int { return a - b } func Mul(a, b int) int { return a * b } func Div(a, b int) int { return a / b } And the C program that calls these functions

gccgo on Precise

此生再无相见时 提交于 2019-12-04 04:38:43
When trying to link with gccgo on Precise, I get this linking error: matt@matt-1005P:~/src/gopath/src/meme$ gccgo cmd/meme/main.go -o meme /usr/bin/ld: cannot find -lgcc_s collect2: error: ld returned 1 exit status There are reports of this error, but no clean solutions. How do I fix it? gccgo (Ubuntu/Linaro 4.7.0-0ubuntu4) 4.7.0 Linux matt-1005P 3.2.0-24-generic-pae #38-Ubuntu SMP Tue May 1 16:40:26 UTC 2012 i686 i686 i386 GNU/Linux This was recently brought up on the golang-nuts group: compiling with gccgo from packaged binaries . It's a known issue in Ubuntu ( Bug #966570 ). To work around