PATCH: Support for Pascal strings

Joseph S. Myers jsm28@cam.ac.uk
Fri Jun 15 17:24:00 GMT 2001


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'm not in favour of adding more stuff to CPP to support non-C
> languages.  We've already removed support for random things we used to

I agree this extension is a mess and a bad idea.  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.)

-- 
Joseph S. Myers
jsm28@cam.ac.uk



More information about the Gcc-patches mailing list