I have a program that needs two different values of the same variable depending on the state of the program.
Function is declared in header (test.inc):
void function_a(int pr)
{
if (pr == 1)
enum{
a = 5,
b = 5,
c = 5,
};
else
enum{
a = 2,
b = 2,
c = 2,
};
}
And program: (main.c)
int main() {
function_a(1);
printf("%d",a);
return (EXIT_SUCCESS);
}
After compiling it say:
main.c:26: error: `a' undeclared (first use in this function)
main.c:26: error: (Each undeclared identifier is reported only once
main.c:26: error: for each function it appears in.)
How to make a global declaration using enum in function located in header?
Thank you