[comp.sys.amiga] Don't forget the comma

FSJTM@ALASKA.BITNET (...Ar Henchou Kuzh...) (10/20/88)

[]
Has anyone else run into this "feature" of Manx C?
It happens with both 3.4b and 3.6a (at least, the ones I have).
Minimal case -

char *array[] = { "s1" "s2" };

That's it.
Now, it seems obvious to me (and every other compiler I
have used) that this is a syntax error.  But the Manx compiler never even
burps.  What it does do is concat "s1" and "s2" into "s1s2" and put just the
one pointer into array.  This one took me quite a while to find once when
I had a large array and forgot a few commas.
I've sent a note off to Manx (since long distance calls from here can
cost an arm and a leg), but from what I've been hearing on the net about their
support, I don't expect them to reply (at least, I'm not holding my breath).
Just thought I'd see if anyone else knew about this, and maybe save someone
a few hours of  head-beating with a debugger.
[jtm]

                John McCranie      FSJTM@ALASKA
                Box 900306
                University of Alaska, Fairbanks 99775-1040

Hawk looks down from lofty flight  Dzur stalks and blends with night.

ali@polya.Stanford.EDU (Ali T. Ozer) (10/23/88)

In article <8810192323.AA21251@jade.berkeley.edu> <FSJTM%ALASKA.BITNET@jade.berkeley.edu> writes:
>Has anyone else run into this "feature" of Manx C?
>char *array[] = { "s1" "s2" };
>Now, it seems obvious to me (and every other compiler I
>have used) that this is a syntax error.  But the Manx compiler never even
>burps.  What it does do is concat "s1" and "s2" into "s1s2" ...

That *is* a feature! ANSI C states that strings can be concatanated
as in the above case. This lets you break long strings into multiple lines to
make your source look prettier. Seems like Manx does the ANSI thing
in this case (instead of giving you a syntax error).

Ali Ozer

bader+@andrew.cmu.edu (Miles Bader) (10/23/88)

FSJTM@ALASKA.BITNET (...Ar Henchou Kuzh...) writes:
> char *array[] = { "s1" "s2" };
> Now, it seems obvious to me (and every other compiler I
> have used) that this is a syntax error.  But the Manx compiler never even
> burps.  What it does do is concat "s1" and "s2" into "s1s2" and put just the

In ANSI c, putting two string literals next to one another like that
is supposed to be equivalent to a string literal that is the
concatenation of the two.  So manx is correct by that standard...

-Miles

jyegiguere@lotus.waterloo.edu (Eric Giguere) (10/23/88)

In article <8810192323.AA21255@jade.berkeley.edu> <FSJTM%ALASKA.BITNET@jade.berkeley.edu> writes:
>[]
>Has anyone else run into this "feature" of Manx C?
>It happens with both 3.4b and 3.6a (at least, the ones I have).
>Minimal case -
>
>char *array[] = { "s1" "s2" };
>
>That's it.
>Now, it seems obvious to me (and every other compiler I
>have used) that this is a syntax error.  But the Manx compiler never even
>burps.  What it does do is concat "s1" and "s2" into "s1s2" and put just the
>one pointer into array.  This one took me quite a while to find once when
>I had a large array and forgot a few commas.

This isn't a bug... I imagine it's one step in Manx' upgrading to
ANSI C.  In ANSI C, two strings separated only by whitespace are
automatically concatenated.... useful for long strings.

--
---------------------------------------------------------------------------
Eric Giguere                    268 Phillip St. #CL-46, Waterloo, Ont. N2L 6G9
jyegiguere@lotus.waterloo.edu   (519) 746-0792
GIGUERE@WATCSG.BITNET           "No, that's not how you pronounce it..." 

toebes@sas.UUCP (John Toebes) (10/24/88)

In article <8810192323.AA21251@jade.berkeley.edu> <FSJTM%ALASKA.BITNET@jade.berkeley.edu> writes:
>[]
>Has anyone else run into this "feature" of Manx C?
>It happens with both 3.4b and 3.6a (at least, the ones I have).
>Minimal case -
>
>char *array[] = { "s1" "s2" };
>
>That's it.
>Now, it seems obvious to me (and every other compiler I
>have used) that this is a syntax error.  But the Manx compiler never even
>burps.  What it does do is concat "s1" and "s2" into "s1s2" and put just the
>one pointer into array.
The automatic concatenation of strings is a feature that has been introduced
by the ANSI comittee.  It is actually quite useful when you want to do something
like:
     #define CSI "\x9B"
     #define EEOL CSI "K"
     printf(EEOL "This is a string" );
With the ANSI standard recently voted out, expect to see more compilers
performing this type of operation, not less.

/*---------------------All standard Disclaimers apply---------------------*/
/*----Working for but not officially representing SAS or Lattice Inc.-----*/
/*----John A. Toebes, VIII             usenet:...!mcnc!rti!sas!toebes-----*/
/*------------------------------------------------------------------------*/

mrr@amanpt1.zone1.com (Mark Rinfret) (10/24/88)

In article <8810192323.AA21251@jade.berkeley.edu>, FSJTM@ALASKA.BITNET (...Ar Henchou Kuzh...) writes:
> []
> Has anyone else run into this "feature" of Manx C?
> It happens with both 3.4b and 3.6a (at least, the ones I have).
> Minimal case -
> 
> char *array[] = { "s1" "s2" };
> 
> That's it.
> Now, it seems obvious to me (and every other compiler I
> have used) that this is a syntax error.  But the Manx compiler never even
> burps.  What it does do is concat "s1" and "s2" into "s1s2" and put just the
> one pointer into array.  

Believe it or not, this is a FEATURE, not a bug.  Look in paragraph 3.7 of
the "Compiler" section of your reference manual.  The heading is "String
merging" - what the compiler does when it finds adjacent character strings.
I suppose this is useful for defining long strings which don't fit on
one line.  The example in the book illustrates the construction of a string
containing preprocessor defined symbols.

Mark

-- 
< Mark R. Rinfret,  mrr@amanpt1.ZONE1.COM | ...rayssd!galaxia!amanpt1!mrr    >
< HyperView Systems Corp.               Home: 401-846-7639                   >
< 28 Jacome Way                         Work: 401-849-9390 x301              >
< Middletown, RI 02840                  Hypermedia R Us!                     >

glennl@cit-vlsi.Caltech.Edu (Glenn M. Lewis) (10/24/88)

In article <8810192323.AA21251@jade.berkeley.edu> <FSJTM%ALASKA.BITNET@jade.berkeley.edu> writes:
|[]
|Has anyone else run into this "feature" of Manx C?
|It happens with both 3.4b and 3.6a (at least, the ones I have).
|Minimal case -
|char *array[] = { "s1" "s2" };
|...  What it does do is concat "s1" and "s2" into "s1s2" and put just the
|one pointer into array...
|Just thought I'd see if anyone else knew about this, and maybe save someone
|a few hours of  head-beating with a debugger...
|                John McCranie      FSJTM@ALASKA

	On page cc.20 (in the Compiler section) of the Manx Aztec C manual,
under section 3.7, it says:

	The compiler will merge adjacent character strings.  For example,
printf("file=" __FILE__ " line = %d func= " __FUNC__ , __LINE__ );


							-- Glenn Lewis

glennl@vlsi.caltech.edu

lapin@ihuxy.ATT.COM (Tweedle Dee & Tweedle Dum) (10/25/88)

In article <8810192323.AA21251@jade.berkeley.edu> <FSJTM%ALASKA.BITNET@jade.berkeley.edu> writes:
>[]
>Has anyone else run into this "feature" of Manx C?
>It happens with both 3.4b and 3.6a (at least, the ones I have).
>Minimal case -
>
>char *array[] = { "s1" "s2" };
>
>That's it.
>Now, it seems obvious to me (and every other compiler I
>have used) that this is a syntax error.  But the Manx compiler never even
>burps.

This is not an error.  According to the proposed ANSI C standard,
the two strings are concatentated, yielding "s1s2".  The purpose
of this is so that long text lines can still be readable.

e.g.
	char	*msg = "The quick brown fox jumped over the "
		       "lazy brown dog.";

My source of information:
	The C Programming Language 2nd Ed. (pg. 38)
	Kernigan/Ritchie
	Prentice Hall, 1988
	
				David Roch
				...!att!ihuxy!lapin
				or lapin@ihuxy.att.com