Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22016

implicit declaration of function ‘_beginthread’ when call go library from c code

$
0
0

i want to call go method in c code os is windows10 i use Cygwin64 Terminal

main.go

package main

import "C"

func main() {}

//export number_add_mod
func number_add_mod(a, b, mod C.int) C.int {
    return (a + b) % mod
}

_test_main.c

#include "number.h"

#include <stdio.h>

int main() {
    int a = 10;
    int b = 5;
    int c = 12;

    int x = number_add_mod(a, b, c);
    printf("(%d+%d)%%%d = %d\n", a, b, c, x);

    return 0;
}

when i run

go build -buildmode=c-archive -o number.a

report error

# runtime/cgo
gcc_libinit_windows.c: in function‘x_cgo_sys_thread_create’:
gcc_libinit_windows.c:57:12: error:implicit declaration of function ‘_beginthread’; did you mean ‘OpenThread’? [-Werror=implicit-function-declaration]
  thandle = _beginthread(func, 0, arg);
            ^~~~~~~~~~~~
            OpenThread
cc1:
go: failed to remove work dir: GetFileInformationByHandle D:\cygwin64new\tmp\go-build109746670\NUL: Incorrect function.
make: *** [Makefile:5:default]

Viewing all articles
Browse latest Browse all 22016

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>