Commit 8543cc56 authored by David Crawshaw's avatar David Crawshaw

misc/cgo/testcarchive: avoid bad pointer passing

Change-Id: Ifbcc0eb24834f2f7d3b160d1dc911209723d9797
Reviewed-on: https://go-review.googlesource.com/8863Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 4345a9fc
...@@ -4,15 +4,13 @@ ...@@ -4,15 +4,13 @@
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
typedef struct { char *p; intmax_t n; } GoString;
extern signed char DidInitRun(); extern signed char DidInitRun();
extern signed char DidMainRun(); extern signed char DidMainRun();
extern GoString FromPkg(); extern int32_t FromPkg();
int main(void) { int main(void) {
GoString res; int32_t res;
if (DidMainRun()) { if (DidMainRun()) {
fprintf(stderr, "ERROR: buildmode=c-archive should not run main\n"); fprintf(stderr, "ERROR: buildmode=c-archive should not run main\n");
...@@ -25,8 +23,8 @@ int main(void) { ...@@ -25,8 +23,8 @@ int main(void) {
} }
res = FromPkg(); res = FromPkg();
if (strcmp(res.p, "str")) { if (res != 1024) {
fprintf(stderr, "ERROR: FromPkg()='%s', want 'str'\n", res.p); fprintf(stderr, "ERROR: FromPkg()=%d, want 1024\n", res);
return 2; return 2;
} }
......
...@@ -7,4 +7,4 @@ package p ...@@ -7,4 +7,4 @@ package p
import "C" import "C"
//export FromPkg //export FromPkg
func FromPkg() string { return "str" } func FromPkg() int32 { return 1024 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment