This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C-string length at compile time


Sebastian Huber <sebastian-huber@web.de> wrote:
> is it possible to get the length of a C-string at compile time?

sizeof "string literal" == strlen("string literal")+1
sizeof includes the null character, unlike strlen.

> Or is maybe strlen() evaluated from the compiler if I switch the
> optimization on?

I suspect it might be.


paul


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]