|
| 1 | +package main |
| 2 | + |
| 3 | +/* |
| 4 | +#include<stdio.h> |
| 5 | +void f_char(char in) { |
| 6 | + printf("char %c\n", in); |
| 7 | +} |
| 8 | +void f_schar(signed char in) { |
| 9 | + printf("signed char %X\n", in); |
| 10 | +} |
| 11 | +void f_uchar(unsigned char in) { |
| 12 | + printf("unsigned char %c\n", in); |
| 13 | +} |
| 14 | +void f_short(short in) { |
| 15 | + printf("short %d\n", in); |
| 16 | +} |
| 17 | +void f_ushort(unsigned short in) { |
| 18 | + printf("unsigned short %u\n", in); |
| 19 | +} |
| 20 | +void f_int(int in) { |
| 21 | + printf("int %d\n", in); |
| 22 | +} |
| 23 | +void f_uint(unsigned int in) { |
| 24 | + printf("unsigned int %u\n", in); |
| 25 | +} |
| 26 | +void f_long(long in) { |
| 27 | + printf("long %X\n", in); |
| 28 | +} |
| 29 | +void f_ulong(unsigned long in) { |
| 30 | + printf("unsigned long %X\n", in); |
| 31 | +} |
| 32 | +void f_longlong(long long in) { |
| 33 | + printf("long long %X\n", in); |
| 34 | +} |
| 35 | +void f_ulonglong(unsigned long long in) { |
| 36 | + printf("unsigned long long %X\n", in); |
| 37 | +} |
| 38 | +void f_float(float in) { |
| 39 | + printf("float %e\n", in); |
| 40 | +} |
| 41 | +void f_double(double in) { |
| 42 | + printf("float %e\n", in); |
| 43 | +} |
| 44 | +*/ |
| 45 | +import "C" |
| 46 | +import "math" |
| 47 | + |
| 48 | +func main() { |
| 49 | + C.f_char(C.char(42)) |
| 50 | + C.f_schar(C.schar(-42)) |
| 51 | + C.f_uchar(C.uchar(42)) |
| 52 | + |
| 53 | + C.f_short(C.short(-42)) |
| 54 | + C.f_ushort(C.ushort(42)) |
| 55 | + |
| 56 | + C.f_int(C.int(-42)) |
| 57 | + C.f_uint(C.uint(math.MaxInt32)) |
| 58 | + |
| 59 | + C.f_long(C.long(-42)) |
| 60 | + C.f_ulong(C.ulong(math.MaxUint64)) |
| 61 | + |
| 62 | + C.f_longlong(C.longlong(math.MaxInt64)) |
| 63 | + C.f_ulonglong(C.ulonglong(math.MaxUint64)) |
| 64 | + |
| 65 | + C.f_float(C.float(math.MaxFloat32)) |
| 66 | + C.f_double(C.double(math.MaxFloat64)) |
| 67 | +} |
0 commit comments