main
| Line | |
|---|
| 1 | /* a_0.c. To be linked with a_1.c and a_2.c. In this translation
|
|---|
| 2 | * unit, struct S is complete.
|
|---|
| 3 | *
|
|---|
| 4 | * By the end of the linking process, the functions will have the
|
|---|
| 5 | * following types:
|
|---|
| 6 | *
|
|---|
| 7 | * f: pointer to struct S {int x;} -> int
|
|---|
| 8 | * h: pointer to struct S {double y;} -> void
|
|---|
| 9 | *
|
|---|
| 10 | * However, h may not have this type until after its body is analyzed.
|
|---|
| 11 | * So after analysis, if a function's type has changed, need to go
|
|---|
| 12 | * back and re-analyze. If you did that you would get an error when
|
|---|
| 13 | * re-analyzing the body of h at the "f(p)", because the type of p
|
|---|
| 14 | * would be incompatible with the type expected by f.
|
|---|
| 15 | */
|
|---|
| 16 | struct S {int x;};
|
|---|
| 17 | int f(struct S *p) {
|
|---|
| 18 | return p->x + 1;
|
|---|
| 19 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.