I build go as a so called by c program
how implement this Send function to make c short array to be used in go as
[]int16
*efficiently *
of course , I can assign it one by one , but it is not an efficient way
package main
import "C"
import "fmt"
//export Summ
func Summ(x, y int) int {
return x + y
}
//export Hello
func Hello(str string) {
fmt.Printf("Hello: %s\n", str)
}
//export Send
func Send(confid string, len int, pcm *C.short) {
//put c.short array to int16 slice/array efficiently , how ?
// memcopy ?
}
func main() {
// We need the main function to make possible
// CGO compiler to compile the package as C shared/archive library
}
go build -buildmode=c-shared -o ws.so ws.go
#include <stdio.h>
#include "ws.h"
int main()
{
printf("This is exptest application.\n");
GoString str = {"Hi JXES", 7};
Hello(str);
printf("sum: %lld\n", Summ(2, 3));
short a[] = {1,2,3,4,5,6};
Send(str,6,a);
return 0;
}
gcc -o cms cms.c ws.so
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/1630397c-79f8-4f25-b855-d6a9f7cdf506%40googlegroups.com.