How can I define a global constant in C? I was told to do some thing like this
in header.h
const u32 g_my_const;
in code.c
#include "header.h"
const u32 g_my_const= 10U;
But I get a compilation error:
error: uninitialized const 'g_my_const' [-fpermissive]
Can some one explain how to do this properly.
const) inhfiles.externthem there. The rule of thumb - if it is creating an object in memory - it should not be in the header.<stdint.h>instead of custom ones. (Unless, like me, you're stuck maintaining code written by people too stubborn to use that and they decided to write their own header for it anyways.)