- Yes, you can use them together.
- And yes, it should exactly match the declaration in the translation unit it’s actually declared in. Unless of course you are participating in the Underhanded C Programming Contest 🙂
The usual pattern is:
- file.h:
extern const int a_global_var;
- file.c:
#include "file.h"
const int a_global_var = /* some const expression */;
Edit: Incorporated legends2k’s comment. Thanks.