forked from cirosantilli/cpp-cheat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotmain.c
More file actions
29 lines (25 loc) · 653 Bytes
/
notmain.c
File metadata and controls
29 lines (25 loc) · 653 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "notmain.h"
/* Link time error: already defined in main. */
#if 0
int main_i = 0;
#endif
/* OK: only declared, not defined. Will be marked as common,
* and default to the one in main.
*/
extern int main_i;
/* Only visible to this file. */
static int static_i = 20;
void notmain_func(
int *main_i_out,
int *static_i_out,
int *static_i_function_out
) {
/* Very similar to static_i, but only visible inside this function. */
static int static_i_function = 30;
main_i++;
static_i++;
static_i_function++;
*main_i_out = main_i;
*static_i_out = static_i;
*static_i_function_out = static_i_function;
}