Bitwise » Forums » Declaration of list of statements
aravind95
Aravind
2 posts
#14854 Declaration of list of statements
4 months, 1 week ago Edited by Aravind on April 7, 2018, 10:18 a.m. Reason: Initial post

Hi

This might be a really silly question:
For a list of statements why is the declaration
BUF(Stmt **stmts) rather than BUF(Stmt *stmts) ?
mmozeiko
Mārtiņš Možeiko
1734 posts / 1 project
#14858 Declaration of list of statements
4 months, 1 week ago Edited by Mārtiņš Možeiko on April 7, 2018, 6:06 p.m.

If you have "int" type and want to have an array of ints then you do "int *" (add an asterix) to point to first element of array
If statement is "Stmt *" type, then to have an array of statements you add an asterix and get "Stmt **". This means you can point to first element of array with "Stmt *" elements - each array element is pointer itself.
osiyuk
Kiril Osiyuk
6 posts
#14862 Declaration of list of statements
4 months, 1 week ago

1
Stmt **stmts
means
1
stmts
is pointer to and/or array of
1
Stmt *
elements
aravind95
Aravind
2 posts
#14892 Declaration of list of statements
4 months ago Edited by Aravind on April 9, 2018, 4:11 p.m.

Got it guys, thanks for the reply.