I have created a golang
program to pass some values to c
program.
I used this example to do so
My simple golang code :
package main
import "C"
func Add() int {
var a = 23
return a
}
func main() {}
Then I compiled this using
go build -o test.so -buildmode=c-shared test.go
My C code :
#include "test.h"
int *http_200 = Add();
When I try to compile it using gcc -o test test.c ./test.so
I get
int *http_200 = Add(); ^ http_server.c:75:17: error: initializer element is not constant
Why I am getting this error? How to initialize that variable properly in my C code.
PS : edited after first comment.