Type is incomplete or unallocatable

I’m writting a C++ wrapper.
Imagine the following project:
src.cpp

#include "src.h"
struct SourceType {
        int foo;
};

src.h:

struct SourceType;

c.h is a C wrapper of this C++ code:

typedef struct SourceType SourceType;
struct SourceType;

wrapper.h is a wrapper for GO:

#pragma once
#include "c.h"

main.go:

package main

/*
#include "wrapper.h"
*/
import "C"

func main() {
	var foo C.SourceType
	_ = foo
}

I’m getting the following error:

# example.com
./main.go:9:6: _Ctype_struct_SourceType is incomplete (or unallocatable); stack allocation disallowed

here is a repo: GitHub - gucio321/cpp-wrapper-demo

oh, ok, got it. I can’t allocate this object, I need to allocate a pointer

Hi @gucio321,
I am running up against the exact same issue doing a go-binding to a c/c++ project. Could you please tell me what you mean by, " I can’t allocate this object, I need to allocate a pointer."? I would like to learn how to solve this for my project as well. Thanks!

Never mind. I understand your comment and was able to make the same changes.