rsc.io/go@v0.0.0-20150416155037-e040fd465409/misc/cgo/testcarchive/main.c (about) 1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #include <stdint.h> 6 #include <stdio.h> 7 8 extern signed char DidInitRun(); 9 extern signed char DidMainRun(); 10 extern int32_t FromPkg(); 11 12 int main(void) { 13 int32_t res; 14 15 if (!DidInitRun()) { 16 fprintf(stderr, "ERROR: buildmode=c-archive init should run\n"); 17 return 2; 18 } 19 20 if (DidMainRun()) { 21 fprintf(stderr, "ERROR: buildmode=c-archive should not run main\n"); 22 return 2; 23 } 24 25 res = FromPkg(); 26 if (res != 1024) { 27 fprintf(stderr, "ERROR: FromPkg()=%d, want 1024\n", res); 28 return 2; 29 } 30 31 return 0; 32 }