Use another language to call a function: Difference between revisions

Content deleted Content added
Sonia (talk | contribs)
No edit summary
Sonia (talk | contribs)
→‎{{header|Go}}: removed comment no longer applicable with updated task code
Line 121: Line 121:
if (0 == Query (Buffer, &Size))
if (0 == Query (Buffer, &Size))
...</lang>
...</lang>
The biggest change is that I renamed main, since it is no longer a C main function. Another small change is that the extern declaration is replaced by an include. The included file is generated by cgo and contains an equivalent extern declaration. And then one more small change, I changed the type of the variable Size from unsigned to size_t. This is to satisfy Go's type matching which is more strict than C's.
The biggest change is that I renamed main, since it is no longer a C main function. Another small change is that the extern declaration is replaced by an include. The included file is generated by cgo and contains an equivalent extern declaration.


In the Go code, below, you see that all main does is call C.Run. The C code is then in the driver's seat.
In the Go code, below, you see that all main does is call C.Run. The C code is then in the driver's seat.