August 2019
Beginner to intermediate
798 pages
17h 2m
English
The relevant C code can be found in the willUseGo.c source file, which will be presented in two parts. The first part of willUseGo.c is next:
#include <stdio.h>
#include "usedByC.h"
int main(int argc, char **argv) {
GoInt x = 12;
GoInt y = 23;
printf("About to call a Go function!\n");
PrintMessage();
If you already know C, you will understand why you need to include usedByC.h; this is the way the C code knows about the available functions of a library.
The second part of the C program is next:
GoInt p = Multiply(x,y);
printf("Product: %d\n",(int)p);
printf("It worked!\n");
return 0;
}
The GoInt p variable is needed for getting an integer value from a Go function, which is converted to a C integer using the (int) p notation. ...
Read now
Unlock full access