Skip to content

Instantly share code, notes, and snippets.

@zokier zokier/build
Last active Dec 28, 2015

Embed
What would you like to do?
Administrator@WIN-CUTEPBGVI8S /d/big_struct
$ cat main.c
#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>
typedef struct TwoU64s {
uint64_t one;
uint64_t two;
} TwoU64s_t;
extern TwoU64s_t f(TwoU64s_t);
int main() {
TwoU64s_t foo = { 42, 1337 };
TwoU64s_t bar = f(foo);
printf("foo: %"PRIu64" %"PRIu64"\n", foo.one, foo.two);
printf("bar: %"PRIu64" %"PRIu64"\n", bar.one, bar.two);
return 0;
}
Administrator@WIN-CUTEPBGVI8S /d/big_struct
$ cat fn.c
#include <stdint.h>
typedef struct TwoU64s {
uint64_t one;
uint64_t two;
} TwoU64s_t;
TwoU64s_t f(TwoU64s_t in) {
TwoU64s_t out = { in.one + 10, in.two + 20 };
return out;
}
Administrator@WIN-CUTEPBGVI8S /d/big_struct
$ clang -c fn.c
Administrator@WIN-CUTEPBGVI8S /d/big_struct
$ clang -o clang_out.exe main.c fn.o
Administrator@WIN-CUTEPBGVI8S /d/big_struct
$ ./clang_out.exe
foo: 42 1337
bar: 52 1357
Administrator@WIN-CUTEPBGVI8S /d/big_struct
$ gcc -o gcc_out.exe main.c fn.o
Administrator@WIN-CUTEPBGVI8S /d/big_struct
$ ./gcc_out.exe
foo: 5742371274752 8462087103658852352
bar: 5828270620672 180388626432
Administrator@WIN-CUTEPBGVI8S /d/big_struct
$ gcc -c fn.c
Administrator@WIN-CUTEPBGVI8S /d/big_struct
$ clang -o clang_out.exe main.c fn.o
Administrator@WIN-CUTEPBGVI8S /d/big_struct
$ ./clang_out.exe
foo: 180388626432 5742371274752
bar: 223342514314 5828270620672
Administrator@WIN-CUTEPBGVI8S /d/big_struct
$ gcc -o gcc_out.exe main.c fn.o
Administrator@WIN-CUTEPBGVI8S /d/big_struct
$ ./gcc_out.exe
foo: 42 1337
bar: 52 1357
Administrator@WIN-CUTEPBGVI8S /d/big_struct
$ gcc --version
gcc.exe (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Administrator@WIN-CUTEPBGVI8S /d/big_struct
$ clang --version
clang version 3.4 (trunk 194593) (llvm/trunk 194592)
Target: i686-pc-mingw32
Thread model: posix
Administrator@WIN-CUTEPBGVI8S /d/big_struct
$
#include <stdint.h>
typedef struct TwoU64s {
uint64_t one;
uint64_t two;
} TwoU64s_t;
TwoU64s_t f(TwoU64s_t in) {
TwoU64s_t out = { in.one + 10, in.two + 20 };
return out;
}
#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>
typedef struct TwoU64s {
uint64_t one;
uint64_t two;
} TwoU64s_t;
extern TwoU64s_t f(TwoU64s_t);
int main() {
TwoU64s_t foo = { 42, 1337 };
TwoU64s_t bar = f(foo);
printf("foo: %"PRIu64" %"PRIu64"\n", foo.one, foo.two);
printf("bar: %"PRIu64" %"PRIu64"\n", bar.one, bar.two);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.