1// Copyright 2012 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// Issue 3729: cmd/cgo: access errno from void C function 6// void f(void) returns [0]byte, error in Go world. 7 8// +build !windows 9 10package cgotest 11 12/* 13#include <errno.h> 14 15void g(void) { 16 errno = E2BIG; 17} 18 19// try to pass some non-trivial arguments to function g2 20const char _expA = 0x42; 21const float _expB = 3.14159; 22const short _expC = 0x55aa; 23const int _expD = 0xdeadbeef; 24void g2(int x, char a, float b, short c, int d) { 25 if (a == _expA && b == _expB && c == _expC && d == _expD) 26 errno = x; 27 else 28 errno = -1; 29} 30*/ 31import "C" 32 33import ( 34 "syscall" 35 "testing" 36) 37 38func test3729(t *testing.T) { 39 _, e := C.g() 40 if e != syscall.E2BIG { 41 t.Errorf("got %q, expect %q", e, syscall.E2BIG) 42 } 43 _, e = C.g2(C.EINVAL, C._expA, C._expB, C._expC, C._expD) 44 if e != syscall.EINVAL { 45 t.Errorf("got %q, expect %q", e, syscall.EINVAL) 46 } 47} 48