shared c constants in a header

前端 未结 4 1212
庸人自扰
庸人自扰 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:03

    You can simply #define them separate

    #define QUERY1 "SELECT a,b,c "
    #define QUERY2 "FROM table..."
    

    and then join them in one definition

    #define QUERY QUERY1 QUERY2
    

提交回复
热议问题