Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(526)

Delta Between Two Patch Sets: src/cmd/cgo/doc.go

Issue 91520043: code review 91520043: cmd/cgo: document the cgo types also follow Go name spa... (Closed)
Left Patch Set: diff -r 708e129e91a9 https://code.google.com/p/go Created 9 years, 10 months ago
Right Patch Set: diff -r 46d573d68ee6 https://code.google.com/p/go Created 9 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 /* 5 /*
6 6
7 Cgo enables the creation of Go packages that call C code. 7 Cgo enables the creation of Go packages that call C code.
8 8
9 Using cgo with the go command 9 Using cgo with the go command
10 10
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 The C type void* is represented by Go's unsafe.Pointer. 100 The C type void* is represented by Go's unsafe.Pointer.
101 101
102 To access a struct, union, or enum type directly, prefix it with 102 To access a struct, union, or enum type directly, prefix it with
103 struct_, union_, or enum_, as in C.struct_stat. 103 struct_, union_, or enum_, as in C.struct_stat.
104 104
105 As Go doesn't have support for C's union type in the general case, 105 As Go doesn't have support for C's union type in the general case,
106 C's union types are represented as a Go byte array with the same length. 106 C's union types are represented as a Go byte array with the same length.
107 107
108 Go structs cannot embed fields with C types. 108 Go structs cannot embed fields with C types.
109 109
110 Cgo translates C types into their equivalent Go types, which will be 110 Cgo translates C types into equivalent unexported Go types.
rsc 2014/05/30 21:08:15 replace paragraph with: Cgo translates C types in
111 defined in the package that uses cgo. Thus a C type used in one Go 111 Because the translations are unexported, a Go package should not
112 package will be a distinct type from the same C type used by another 112 expose C types in its exported API: a C type used in one Go package
113 package. It is recommended, therefore, to confine all cgo components 113 is different from the same C type used in another.
114 in the same Go package.
115
116 Opaque pointers in C (such as void* or pointer to opaque types) will
rsc 2014/05/30 21:08:15 Delete this paragraph. I don't want to fully speci
117 be translated to Go *[0]byte, but different C types will be made
118 incompatible with each other.
119 114
120 Any C function (even void functions) may be called in a multiple 115 Any C function (even void functions) may be called in a multiple
121 assignment context to retrieve both the return value (if any) and the 116 assignment context to retrieve both the return value (if any) and the
122 C errno variable as an error (use _ to skip the result value if the 117 C errno variable as an error (use _ to skip the result value if the
123 function returns void). For example: 118 function returns void). For example:
124 119
125 n, err := C.sqrt(-1) 120 n, err := C.sqrt(-1)
126 _, err := C.voidFunc() 121 _, err := C.voidFunc()
127 122
128 Calling C function pointers is currently not supported, however you can 123 Calling C function pointers is currently not supported, however you can
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 be overridden using command line flags: 6l -extld=clang 739 be overridden using command line flags: 6l -extld=clang
745 -extldflags='-ggdb -O3'. If any package in a build includes a .cc or 740 -extldflags='-ggdb -O3'. If any package in a build includes a .cc or
746 other file compiled by the C++ compiler, the go tool will use the 741 other file compiled by the C++ compiler, the go tool will use the
747 -extld option to set the host linker to the C++ compiler. 742 -extld option to set the host linker to the C++ compiler.
748 743
749 These defaults mean that Go-aware build systems can ignore the linking 744 These defaults mean that Go-aware build systems can ignore the linking
750 changes and keep running plain '6l' and get reasonable results, but 745 changes and keep running plain '6l' and get reasonable results, but
751 they can also control the linking details if desired. 746 they can also control the linking details if desired.
752 747
753 */ 748 */
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b