2007-03-01 Paul Brook <paul@codesourcery.com>
[official-gcc.git] / gcc / testsuite / objc.dg / type-stream-1.m
blobedc04e6467bddddc346831c748f9e9f9a7cf5bba
1 /* { dg-options "-fgnu-runtime" } */
2 /* { dg-do run } */
3 #include <objc/typedstream.h>
4 #include <stdio.h>
5 #include <stdlib.h>
7 int main (void)
9   FILE *f; TypedStream *ts;
10   struct T { int a, b; } x = { 1, 2 };
11   f = fopen ("foo", "w"); ts = objc_open_typed_stream (f, OBJC_WRITEONLY);
12   objc_write_type (ts, @encode(struct T), &x);
13   objc_close_typed_stream (ts); fclose (f);
14   f = fopen ("foo", "r"); ts = objc_open_typed_stream (f, OBJC_READONLY);
15   struct T y;
16   objc_read_type (ts, @encode(struct T), &y);
17   if (y.a != 1)
18    abort ();
19   if (y.b != 2)
20    abort ();
21   objc_close_typed_stream (ts); fclose (f);
22   remove ("foo");
23   return 0;