OSDN Git Service

CFStrings for Darwin.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / obj-c++.dg / const-str-8.mm
1 /* Test for assigning compile-time constant-string objects to static variables.  */
2 /* Contributed by Ziemowit Laski <zlaski@apple.com>  */
3
4 /* { dg-options "-fconstant-string-class=Foo" } */
5 /* { dg-do run { target *-*-darwin* } } */
6
7 #include "../objc-obj-c++-shared/Object1.h"
8 #include <stdlib.h>
9
10 @interface Foo: Object {
11   char *cString;
12   unsigned int len;
13 }
14 @end
15
16 #ifdef NEXT_OBJC_USE_NEW_INTERFACE
17 Class _FooClassReference;
18 #else
19 struct objc_class _FooClassReference;
20 #endif
21
22 @implementation Foo : Object
23 - (char *)customString {
24   return cString;
25 }
26 @end
27
28 static const Foo *appKey = @"MyApp";
29 static int CFPreferencesSynchronize (const Foo *ref) {
30   return ref == appKey;
31 }
32
33 static void PrefsSynchronize(void)
34 {
35   if(!CFPreferencesSynchronize(appKey))
36     abort();
37 }
38
39 int main () {
40   PrefsSynchronize();
41   return 0;
42 }
43
44 #include "../objc-obj-c++-shared/Object1-implementation.h"