1
0
mirror of https://github.com/golang/go synced 2024-11-12 09:50:21 -07:00
go/misc/cgo/testcarchive/main.c
David Crawshaw fdab2f92ea misc/cgo/testcarchive: test -buildmode=c-archive
Change-Id: I1668a6885c45180ff88fe673d04cec7eba395ee7
Reviewed-on: https://go-review.googlesource.com/8861
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-13 18:31:07 +00:00

35 lines
751 B
C

// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include <stdint.h>
#include <stdio.h>
#include <string.h>
typedef struct { char *p; intmax_t n; } GoString;
extern signed char DidInitRun();
extern signed char DidMainRun();
extern GoString FromPkg();
int main(void) {
GoString res;
if (DidMainRun()) {
fprintf(stderr, "ERROR: buildmode=c-archive should not run main\n");
return 2;
}
if (!DidInitRun()) {
fprintf(stderr, "ERROR: buildmode=c-archive init should run\n");
return 2;
}
res = FromPkg();
if (strcmp(res.p, "str")) {
fprintf(stderr, "ERROR: FromPkg()='%s', want 'str'\n", res.p);
return 2;
}
return 0;
}