#include
#include
#define GREY 1
#define BLACK 0
#define WHITE 2
typedef struct node * graph;
typedef struct stack * snode;
graph cno
Clang still issues a warning for this. The line
extern int counter = 0;
will trigger the warning:
warning: 'extern' variable has an initializer [-Wextern-initializer]
This warning is not important, as defining the variable with
int counter = 0;
still yields a static duration and external linkage by default. Indeed, if no storage-class specifier is provided, the defaults are:
extern for all functionsextern for objects at file scopeauto for objects at block scopeThere is also something called a tentative definition which is an external declaration without an initializer, and either without a storage-class specifier or with the specifier static.
A tentative definition is a declaration that may or may not act as a definition. If an actual external definition is found earlier or later in the same translation unit, then the tentative definition just acts as a declaration.
So the following line
int counter;
is a tentative definition that declares and defines counter with the implicit initializer = 0 (or, for array, structure, and union types, = {0}).