Re: C Strings and String Literals. (Was: Pascal rides again)

2024-07-15 Thread Alejandro Colomar
(2 years later...) Hi Doug! On 11/13/22 23:39, Douglas McIlroy wrote: > > Wouldn't it be nice to use -Wunterminated-strings and let the > > compiler yell at me if I write a string literal [that's too long]? > > A good idea. Assuming you use gcc, please propose it at > https://gcc.gnu.org/bugzilla

Re: C Strings and String Literals. (Was: Pascal rides again)

2022-11-14 Thread Alejandro Colomar
Hi Doug! On 11/13/22 23:39, Douglas McIlroy wrote: > Wouldn't it be nice to use -Wunterminated-strings and let the compiler yell at me if I write a string literal [that's too long]? A good idea. Thanks! Assuming you use gcc, please propose it at https://gcc.gnu.org/bugzilla. Yep I use

Re: C Strings and String Literals. (Was: Pascal rides again)

2022-11-13 Thread Douglas McIlroy
> Wouldn't it be nice to use -Wunterminated-strings and let the > compiler yell at me if I write a string literal [that's too long]? A good idea. Assuming you use gcc, please propose it at https://gcc.gnu.org/bugzilla. Apropos of help from the compiler, I normally run gcc via this script and sta

Re: C Strings and String Literals. (Was: Pascal rides again)

2022-11-13 Thread Larry McVoy
On Sun, Nov 13, 2022 at 10:25:35PM +0100, Alejandro Colomar wrote: > On 11/13/22 22:20, Alejandro Colomar wrote: > >See for example some (part of a) change that I did for optimizing some > >code, where I transformed pointers to char to char arrays (following > >Ulrich Drepper's article about librar

Re: C Strings and String Literals. (Was: Pascal rides again)

2022-11-13 Thread Alejandro Colomar
BTW, just as a curiosity, I'm facing a code base full of unterminated strings, and the good thing is it uses u_char* everywhere. So I'll do some small change to make sure I know which strings are terminated by starting to use char* on those. Then, the compiler will warn me if I mix them at any

Re: C Strings and String Literals. (Was: Pascal rides again)

2022-11-13 Thread Alejandro Colomar
Hi Larry! On 11/13/22 21:45, Larry McVoy wrote: > None of this surprises me but it reminds me of how I described C to > my older son who is learning computer science. > > C is sort of like driving a sports car on a narrow mountain road with > no guard rails. If you like to text while you drive,

Re: C Strings and String Literals. (Was: Pascal rides again)

2022-11-13 Thread Alejandro Colomar
Hi Ralph, On 11/13/22 21:08, Ralph Corderoy wrote: Hi Branden, C doesn't _really_ have strings, except at the library level. It has character arrays and one grain of syntactic sugar for encoding "string literals", which should not have been called that because whether they get the null termina

Re: C Strings and String Literals. (Was: Pascal rides again)

2022-11-13 Thread Larry McVoy
None of this surprises me but it reminds me of how I described C to my older son who is learning computer science. C is sort of like driving a sports car on a narrow mountain road with no guard rails. If you like to text while you drive, C is not for you. If you can't keep your eyes on the road,

C Strings and String Literals. (Was: Pascal rides again)

2022-11-13 Thread Ralph Corderoy
Hi Branden, > C doesn't _really_ have strings, except at the library level. > It has character arrays and one grain of syntactic sugar for encoding > "string literals", which should not have been called that because > whether they get the null terminator is context-dependent. > > char a[5]