[comp.lang.c] A new one on me...

bzs@world.std.com (Barry Shein) (11/29/89)

In a pd program I ran into a line like this:

	if(c == '')
	...

Sun 4.0.3 cc gives me a non-fatal error (empty character constant.)

Is there any meaning assigned to this? I assume it meant something in
Turbo/C (under which the program was developed.)

It surprised me enough that I thought the language lawyers would be at
least amused. Darn, we could have used that for our favorite feature!
-- 
        -Barry Shein

Software Tool & Die, Purveyors to the Trade         | bzs@world.std.com
1330 Beacon St, Brookline, MA 02146, (617) 739-0202 | {xylogics,uunet}world!bzs

gwyn@smoke.BRL.MIL (Doug Gwyn) (11/30/89)

In article <1989Nov28.221224.6106@world.std.com> bzs@world.std.com (Barry Shein) writes:
>In a pd program I ran into a line like this:
>	if(c == '')

It's quite possible that in the original source code there was a control
character between the '', for example ctrl-G for ASCII BEL.  I've seen a
fair amount of code like that.

The control character could have been removed by somebody's mailer, text
editor, or numerous other "helpful" utilities.

comeau@utoday.UUCP (Greg Comeau) (11/30/89)

In article <1989Nov28.221224.6106@world.std.com> bzs@world.std.com (Barry Shein) writes:
>In a pd program I ran into a line like this: if(c == '') ...
>Sun 4.0.3 cc gives me a non-fatal error (empty character constant.)
>Is there any meaning assigned to this?

The Sun compiler's message is indeed appropriate.
There is no meaning applied to '' and it had better be an error,
even as far back as K&R C.

leoh@hardy.harris.com (Leo Hinds) (11/30/89)

In article <1989Nov28.221224.6106@world.std.com> bzs@world.std.com (Barry Shein) writes:

>In a pd program I ran into a line like this:

>	if(c == '')

>Sun 4.0.3 cc gives me a non-fatal error (empty character constant.)

>Is there any meaning assigned to this? I assume it meant something in
>Turbo/C (under which the program was developed.)


Barry:

I ran into the same thing ... trying to help out a friend of mine who pulled it
off of the net.  On our system ... it would provide the same message ... but not
produce an ".o".  Trying the same piece of code on Turbo showed that turbo
interpreted that as being '\0' ... so that's how the program was changed ...

Leo Hinds

brianh@hpcvia.CV.HP.COM (brian_helterline) (12/01/89)

bzs@world.std.com (Barry Shein) writes:

>In a pd program I ran into a line like this:
>
>	if(c == '')
>	...

>Sun 4.0.3 cc gives me a non-fatal error (empty character constant.)

>Is there any meaning assigned to this? I assume it meant something in
>Turbo/C (under which the program was developed.)

>It surprised me enough that I thought the language lawyers would be at
>least amused. Darn, we could have used that for our favorite feature!
>-- 
>        -Barry Shein

>Software Tool & Die, Purveyors to the Trade         | bzs@world.std.com
>1330 Beacon St, Brookline, MA 02146, (617) 739-0202 | {xylogics,uunet}world!bzs
>----------

	I believe the code was comparing c to the null character '\0' 
	although I have never seen an C that looked like that.


-------------------------------------------------------------------------------
Brian Helterline                                        brianh@hpcvia.cv.HP.COM
Hewlett Packard                                         ..!hp-pcd!hpcvia!brianh
Corvallis, OR  97330                            "Life's a beach, then you fry!"

mccaugh@s.cs.uiuc.edu (12/01/89)

 This is just a guess, but it seems that -- since '' might refer to the
 null string, which is indicated in C by the lone null-terminator '\0' --
 that the notation: c == '' (c being of type char) might be a local ver-
 nacular for: c == '\0'. (This is in spite of the fact that the null
 string should be indicated in C by "" rather than by ''!)

 Scott

ORCUTT@cc.utah.edu (12/03/89)

I just tried the following code in Turbo C.  It outputs
"0" and gives no warning.

#include <stdio.h>             /* prototype of printf, for what it's worth */

int main()
  {
  printf("%d\n", '');          /* test null character constant */
  return (0);
  }

To answer an earlier question, Turbo C predefines the preprocessor
macro __TURBOC__ as 0x0200 after patch and as something else if
not patched.  It does not define the macro MSDOS.

semicon@watsci.uwaterloo.ca (Robert Adsett) (12/03/89)

In article <35978@cc.utah.edu> ORCUTT@cc.utah.edu writes:
>To answer an earlier question, Turbo C predefines the preprocessor
>macro __TURBOC__ as 0x0200 after patch and as something else if
>not patched.  It does not define the macro MSDOS.
It does, however, define __MSDOS__.



--
		Robert Adsett  <semicon@atsci.UWaterloo.ca>
		Dept. of Phys, Univ. of Waterloo, Waterloo Ont. Canada

matthew@sunpix.UUCP ( Sun Visualization Products) (12/04/89)

In article <35978@cc.utah.edu> ORCUTT@cc.utah.edu writes:
>
>It does not define the macro MSDOS.
>

But it does define the macro __MSDOS__ and gives it the value of 1.

i.e.
	#define __MSDOS__ 1


-- 
Matthew Lee Stier                            |
Sun Microsystems ---  RTP, NC  27709-3447    |     "Wisconsin   Escapee"
uucp:  sun!mstier or mcnc!rti!sunpix!matthew |
phone: (919) 469-8300 fax: (919) 460-8355    |

kbad@atari.UUCP (Ken Badertscher) (12/05/89)

semicon@watsci.uwaterloo.ca (Robert Adsett) writes:
| In article <35978@cc.utah.edu> ORCUTT@cc.utah.edu writes:
| > It does not define the macro MSDOS.
| It does, however, define __MSDOS__.

The Atari ST version of Turbo C doesn't define __MSDOS__.
<@_@>
-- 
   |||   Ken Badertscher  (ames!atari!kbad)
   |||   Atari R&D System Software Engine
  / | \  #include <disclaimer>