This is the mail archive of the gcc-patches@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]

Re: PATCH: Support for Pascal strings


"Joseph S. Myers" wrote:
> 
> On Sat, 16 Jun 2001, Neil Booth wrote:
> 
> > Ziemowit Laski wrote:-
> > > I would humbly like to propose to add support for Pascal-style
> > > string literals in gcc.
> >

> I agree this extension is a mess and a bad idea.

Perhaps, but it's already been in use in the Mac world for about 15
years or so, and there are millions of lines of code that use \p in
strings.  I first implemented it in GCC in 1989 or so, so it's not
even new for GCC.

> Besides, you can already
> approximate what you want without further extensions:
>
> #define __pascal_string(s)                                              \
>   ((const unsigned char *)&(struct {                                    \
>                               unsigned char __len;                      \
>                               const char __string[__builtin_strlen(s)]; \
>                             }){ __builtin_strlen(s), s })
> 
> (Note, however, that the result of __pascal_string here has only C99 block
> scope, which may not be what you want, and that there are some bugs in the
> handling of compound literals.)

Interesting, but unless you can come up with a macro that expands \p in a
string literal into this, it's a non-starter.  Mac developers will just
use a proprietary compiler instead of a GCC that doesn't support \p.

Stan


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