shared c constants in a header

前端 未结 4 1210
庸人自扰
庸人自扰 2021-01-01 10:23

I want to share certain C string constants across multiple c files. The constants span multiple lines for readability:

const char *QUERY = \"SELECT a,b,c \"
         


        
4条回答
  •  被撕碎了的回忆
    2021-01-01 10:49

    In some .c file, write what you've written. In the appropriate .h file, write

    extern const char* QUERY; //just declaration
    

    Include the .h file wherever you need the constant

    No other good way :) HTH

提交回复
热议问题