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


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


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