Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
compoundlit: array ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Jul 20, 2022
1 parent 173dc73 commit 019f67c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ Hi, 3.1
- [x] Boolean, Integer
- [x] Float, Complex Imaginary
- [x] Character, String
- [ ] Array: `(T[]){ expr1, expr2, ... }`
- [ ] Array Pointer: `&(T[]){ expr1, expr2, ... }`
- [x] Array: `(T[]){ expr1, expr2, ... }`
- [x] Array Pointer: `&(T[]){ expr1, expr2, ... }`
- [ ] Struct: `struct T{ expr1, expr2, ... }`

### Initialization
Expand Down
7 changes: 6 additions & 1 deletion testdata/compoundlit/compoundlit.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#include <stdio.h>

void f(unsigned short a[]) {
printf("%d, %d, %d\n", a[0], a[1], a[2]);
printf("%d, %d, %d\n", (int)a[0], (int)a[1], (int)a[2]);
}

void g(unsigned short (*a)[3]) {
printf("%d, %d, %d\n", (int)(*a)[0], (int)(*a)[1], (int)(*a)[2]);
}

int main() {
f((unsigned short [3]){ 0x330e, 0, 16 });
g(&(unsigned short [3]){ 0x330e, 0, 16 });
return 0;
}

0 comments on commit 019f67c

Please sign in to comment.