Last active
August 29, 2015 14:23
-
-
Save bnagy/eb2648248933826156c0 to your computer and use it in GitHub Desktop.
buildmode c-shared
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Created by "go tool cgo" - DO NOT EDIT. */ | |
/* package github.com/bnagy/cshared */ | |
/* Start of preamble from import "C" comments. */ | |
/* End of preamble from import "C" comments. */ | |
/* Start of boilerplate cgo prologue. */ | |
#ifndef GO_CGO_PROLOGUE_H | |
#define GO_CGO_PROLOGUE_H | |
typedef signed char GoInt8; | |
typedef unsigned char GoUint8; | |
typedef short GoInt16; | |
typedef unsigned short GoUint16; | |
typedef int GoInt32; | |
typedef unsigned int GoUint32; | |
typedef long long GoInt64; | |
typedef unsigned long long GoUint64; | |
typedef GoInt64 GoInt; | |
typedef GoUint64 GoUint; | |
typedef __SIZE_TYPE__ GoUintptr; | |
typedef float GoFloat32; | |
typedef double GoFloat64; | |
typedef __complex float GoComplex64; | |
typedef __complex double GoComplex128; | |
// static assertion to make sure the file is being used on architecture | |
// at least with matching size of GoInt. | |
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; | |
typedef struct { char *p; GoInt n; } GoString; | |
typedef void *GoMap; | |
typedef void *GoChan; | |
typedef struct { void *t; void *v; } GoInterface; | |
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; | |
#endif | |
/* End of boilerplate cgo prologue. */ | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
extern GoInt64 Test(); | |
#ifdef __cplusplus | |
} | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "C" | |
// The export directive below doesn't work with a space between // and export! | |
//export Test | |
func Test() int64 { | |
return 42 | |
} | |
func main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ls | |
foo.h libfoo.so test.c | |
$ clang test.c -pedantic -Weverything -lfoo -L. -o foo -Wl,-rpath,. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "foo.h" | |
int | |
main() { | |
GoInt answer; | |
answer = Test(); | |
printf("%lld\n", answer); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment