C and Go without CGO
skullcountry.com
C and Go without CGO
1–10 of 21 posts
Re: C and Go without CGO
#2Re: C and Go without CGO
#3In the article, a file called chello.c and a file called gohello.go are created - do the filenames have any significance? How does the go compiler and linker know what to do here?
Re: C and Go without CGO
#4I'd love to know how this works behind the scenes. In the article, a file called chello.c and a file called gohello.go are created - do the filenames have any significance? How does the go compiler and linker know what to do here?
6g,6c, and 6a produce object files on amd64. 6l is the linker which combines them. Honestly I had a little trouble running the commands individually so I just used go build.
Re: C and Go without CGO
#5Re: C and Go without CGO
#6"as fast as physically possible on your CPU architecture" is a ludicrous phrase full of misunderstanding.
Re: C and Go without CGO
#7"as fast as physically possible on your CPU architecture" is a ludicrous phrase full of misunderstanding.
Can you suggest a better one?
As for a suggestion how about just “as fast as possible”.
Re: C and Go without CGO
#8- Using C code is inherently unsafe, not just because it unholsters all the C footguns, but because you can address any symbol in the runtime. With great power comes great responsibility.
- The Go 1 compatibility guarantee does not extend to C code.
- C functions cannot be inlined.
- Escape analysis cannot follow values passed into C functions.
- Code coverage does not extend to C functions.
- The C compilers (5c, 6c, 8c) are not as optimised as their companion Go compilers, you may find that the code generated is not as efficient as the same code in Go.
- You are writing plan 9 style C code, which is a rough analogue of C89.
[0]: http://dave.cheney.net/2013/09/07/how-to-include-c-code-in-y...
Re: C and Go without CGO
#9Re: C and Go without CGO
#10Can anyone explain the use of the "·" character?
f = os.NewFile(3, "/dev/zero") # Go
you would use f = os·NewFile(3, "/dev/zero"); # C