I have a slice that I need to change from _Ctype_int to int.
fmt.Printf("Slice Type: %T", slice) //Returns Slice Type: []main._Ctype_int
Do you know of a simple conversion? Thank you!
Here is the code that returns a pointer to array in C++
#include "camera.hxx"
#include <iostream>
Camera::Camera()
{
}
int* Camera::retrieveDataPointerPerBuffer() {
const int size = 640 * 512;
static int cameraData[size];
for (int i = 0; i < size; i++) {
cameraData[i] = i;
} //Generates dummy 512x640 camera data
int* pSrc = cameraData;
return pSrc;
} //C++ file
This code calls the c++ function in Go.
func myCamera() {
cam := camera.NewCamera()
pSrc := cam.RetrieveDataPointerPerBuffer()
arraySize := 512 * 640
slice := (*[1 << 30]C.int)(unsafe.Pointer(pSrc))[:arraySize:arraySize]
fmt.Printf("
Slice Type: %T
", slice)
}
func main() {
go myCamera()
time.Sleep(15 * time.Millisecond)
}
I am using SWIG to wrap the C++ for Go