This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: C-string length at compile time
- From: prj at po dot cwru dot edu (Paul Jarc)
- To: Sebastian Huber <sebastian-huber at web dot de>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: Fri, 30 Aug 2002 15:22:11 -0400
- Subject: Re: C-string length at compile time
- Organization: What did you have in mind? A short, blunt, human pyramid?
- References: <200208302117.55587.sebastian-huber@web.de>
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