Determine #defined string length at compile time

后端 未结 4 2023
抹茶落季
抹茶落季 2021-02-07 01:28

I have a C-program (an Apache module, i.e. the program runs often), which is going to write() a 0-terminated string over a socket, so I need to know its length.

4条回答
  •  滥情空心
    2021-02-07 01:47

    Use 1+strlen(POLICY) and turn on compiler optimizations. GCC will replace strlen(S) with the length of S at compile time if the value from S is known at compile time.

提交回复
热议问题