summary refs log tree commit diff stats
path: root/tests/misc/tsizeof.nim
blob: 0597535f96a65634b1fafdf927e3875b37147dec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
discard """
  file: "tsize.nim"
  output: "40 3 12 32"
"""
type
  TMyRecord {.final.} = object
    x, y: int
    b: bool
    r: float
    s: string

  TMyEnum = enum
    tmOne, tmTwo, tmThree, tmFour

  TMyArray1 = array[3, uint8]
  TMyArray2 = array[1..3, int32]
  TMyArray3 = array[TMyEnum, float64]

const 
  mysize1 = sizeof(TMyArray1)
  mysize2 = sizeof(TMyArray2)
  mysize3 = sizeof(TMyArray3)

write(stdout, sizeof(TMyRecord))
echo ' ', mysize1, ' ', mysize2, ' ',mysize3