Skip to content

Instantly share code, notes, and snippets.

@egonelbre
Created Feb 8, 2014
Embed
What would you like to do?
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
struct S1 {
int64_t TradeId;
int64_t ClientId;
int VenueCode;
int InstrumentCode;
int64_t Price;
int64_t Quantity;
char Side;
};
struct S2 {
int64_t TradeId;
int64_t ClientId;
int32_t VenueCode;
int32_t InstrumentCode;
int64_t Price;
int64_t Quantity;
char Side;
};
struct S3 {
int64_t TradeId;
int64_t ClientId;
int32_t VenueCode;
int32_t InstrumentCode;
int64_t Price;
int64_t Quantity;
};
int main(int argc, char const *argv[])
{
struct S1 s1;
printf("S1: %i\n", sizeof(s1));
struct S2 s2;
printf("S2: %ld\n", sizeof(s2));
struct S3 s3;
printf("S3: %ld\n", sizeof(s3));
return 0;
}
package main
import (
"fmt"
"reflect"
)
type S1 struct {
TradeId int64
ClientId int64
VenueCode int
InstrumentCode int
Price int64
Quantity int64
Side byte
}
type S2 struct {
TradeId int64
ClientId int64
VenueCode int32
InstrumentCode int32
Price int64
Quantity int64
Side byte
}
type S3 struct {
TradeId int64
ClientId int64
VenueCode int32
InstrumentCode int32
Price int64
Quantity int64
}
func main() {
s1 := reflect.TypeOf(S1{}).Size()
fmt.Printf("S1: %d\n\t%t\n", s1, S1{})
s2 := reflect.TypeOf(S2{}).Size()
fmt.Printf("S2: %d\n\t%t\n", s2, S2{})
s3 := reflect.TypeOf(S3{}).Size()
fmt.Printf("S3: %d\n\t%t\n", s3, S3{})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment