global constants without using #define

前端 未结 2 603
面向向阳花
面向向阳花 2021-02-07 14:04

Ok, I\'m looking to define a set of memory addresses as constants in a .h file that\'s used by a bunch of .c files (we\'re in C, not C++). I want to be able to see the name<

相关标签:
2条回答
  • 2021-02-07 14:32

    If you're compiling with gcc, you can add the -ggdb3 switch, which will tell gcc to store macro information (i.e. #defines) so that they can be used inside gdb.

    0 讨论(0)
  • 2021-02-07 14:47

    Declare the constants in the header file using extern:

    extern const short int SOME_ADDRESS;
    

    then in any, but only one, .c file provide the definition:

    const short int SOME_ADDRESS = 0x0010;
    
    0 讨论(0)
提交回复
热议问题