shared c constants in a header

前端 未结 4 1238
庸人自扰
庸人自扰 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 11:07

    There are several ways

    • place your variables in one file, declare them extern in the header and include that header where needed
    • consider using some external tool to append '\' at the end of your macro definition
    • overcome your laziness and declare your variables as extern in all your files

提交回复
热议问题