...
This noncompliant code example includes a helper()
function that is implicitly declared to have external linkage.
Code Block | ||||
---|---|---|---|---|
| ||||
enum { MAX = 100 }; int helper(int i) { /* perform some computation based on i */ } int main(void) { size_t i; int out[MAX]; for (i = 0; i < MAX; i++) { out[i] = helper(i); } /* ... */ } |
...
This compliant solution declares helper()
to have internal linkage, thereby preventing external functions from using it.
Code Block | ||||
---|---|---|---|---|
| ||||
enum {MAX = 100}; static int helper(int i) { /* perform some computation based on i */ } int main(void) { size_t i; int out[MAX]; for (i = 0; i < MAX; i++) { out[i] = helper(i); } /* ... */ } |
...