Am I missing something with const?
Is there a case where const is supposed to act like static? I've defined a global constant in one file and try to extern it in another and my linker fails. If I remove the const keyword, my program links.
Here is an example of the code that fails to link
File 1
Code:
#include <stdio.h>
int main(void)
{
extern const int my_const;
printf("hello %d\n", my_const);
return 0;
}
File 2
Code:
const int my_const = 7;
Simply removing the const keyword from both files allows me to link.