C-string length at compile time

Wei Qin wqin@EE.Princeton.EDU
Fri Aug 30 12:21:00 GMT 2002



You can use sizeof() instead of strlen(). It will resolve at compile time.

Wei

On Fri, 30 Aug 2002, Sebastian Huber wrote:

> Hallo,
> is it possible to get the length of a C-string at compile time? I have various
> #define CSTRING "blabla"
> in combination with 'strlen( CSTRING)'. Or is maybe strlen() evaluated from
> the compiler if I switch the optimization on?
>
> Ciao
>



More information about the Gcc-help mailing list