OSDN Git Service

original
[gb-231r1-is01/GB_2.3_IS01.git] / system / core / libacc / tests / data / addressOf.c
diff --git a/system/core/libacc/tests/data/addressOf.c b/system/core/libacc/tests/data/addressOf.c
new file mode 100644 (file)
index 0000000..e7acde5
--- /dev/null
@@ -0,0 +1,31 @@
+void testStruct() {
+    struct str {
+        float x;
+        float y;
+    };
+
+    struct str base;
+    int index = 0;
+
+    base.x = 10.0;
+    struct str *s = &base;
+
+    float *v = &(*s).x;
+    float *v2 = &s[index].x;
+    printf("testStruct: %g %g %g\n",base.x, *v, *v2);
+}
+
+void testArray() {
+    int a[2];
+    a[0] = 1;
+    a[1] = 2;
+    int* p = &a[0];
+    int* p2 = a;
+    printf("testArray: %d %d %d\n", a[0], *p, *p2);
+}
+
+int main() {
+    testStruct();
+    testArray();
+    return 0;
+}