From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,2afd440a210c7fb0 X-Google-Attributes: gidf7344,public X-Google-Thread: 1164f8,df8a3dc583bf1f5f X-Google-Attributes: gid1164f8,public From: cornelius@eisner.decus.org (George Cornelius) Subject: Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * Date: 1998/08/28 Message-ID: <1998Aug28.150343.1@eisner>#1/1 X-Deja-AN: 385724963 X-Nntp-Posting-Host: eisner.decus.org References: <0095000017115526000002L062*@MHS> <6rukse$3q0$1@usenet01.srv.cis.pitt.edu> <6s17hi$2g8@post.gsfc.nasa.gov> <6s4o0o$q31@news1.panix.com> <6s6i11$jla$1@vixen.cso.uiuc.edu> X-Trace: news.decus.org 904331027 14231 CORNELIUS [192.67.173.2] Organization: DECUServe Newsgroups: comp.os.vms,comp.sys.dec In article <6s6i11$jla$1@vixen.cso.uiuc.edu>, tsmurphy@cs.uiuc.edu (TERENCE MURPHY) writes: > How do I get the compiler to generate the hello string as a pascal > string? Do compilers typically have a command line option to specify > what kind of strings you can use? In particular, does gcc? > > It seems that the only semi-portable way to do this would be to compile > the program with strings constants as writable, and convert each string > a run-time. This is a serious, serious kludge, and I'd hardly say that > this is a "perfectly free" task (especially since it is likely that > many compilers do not even support writable string constants, so it's > non-portable, which defeats the main purpose of C). As has been mentioned, the definition of a descriptor structure could be encapsulated in a macro and would result in painless generation of suitable string constants; and with an optimizing compiler the strlen() might actually be optimized away so that the run-time cost would be minimal. The effort involved in generating alternative string constants, even without this, turns out to be minor compared to writing and maintaining replacements to all the run-time routines that currently work with null-terminated strings only. May I suggest C++, or, better yet, Java, as the only reasonable way to write "C" code with safe strings? -- George Cornelius cornelius@eisner.decus.org cornelius@mayo.edu