c_mem_safety/innerf.c

36 lines
586 B
C
Raw Normal View History

#include <stdio.h>
int main() {
2025-04-25 21:44:24 +02:00
auto int a = 0;
int b = 20;
int c = 1;
int d = 0;
// See: https://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Nested-Functions.html
2025-04-25 21:44:24 +02:00
inline auto void lf(register int *r) {
a += *r;
2025-04-25 21:44:24 +02:00
int s = a + *r;
inline void deepfun() {
s *= 2;
}
deepfun();
d += s;
}; // semicolon(;) not needeed!
/*
// Same as above... but need auto storage class if you pre-declare
inline auto void lf(register int* r);
2025-04-25 21:44:24 +02:00
// ...
inline void lf(register int* r) {
a += *r;
}; // semicolon(;) not needeed!
*/
lf(&b);
lf(&c);
2025-04-25 21:44:24 +02:00
printf("%d .. %d\n", a, d);
}