Re: program that compiles in C but not in C++?
From: Arthur J. O'Dwyer (ajo_at_nospam.andrew.cmu.edu)
Date: 01/10/04
- Next message: Richard Heathfield: "Re: program that compiles in C but not in C++?"
- Previous message: Nick Hounsome: "Re: how to call C++ from C?"
- In reply to: Nils O. Selåsdal: "Re: program that compiles in C but not in C++?"
- Next in thread: Richard Heathfield: "Re: program that compiles in C but not in C++?"
- Reply: Richard Heathfield: "Re: program that compiles in C but not in C++?"
- Reply: Nils O. Selåsdal: "Re: program that compiles in C but not in C++?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 10 Jan 2004 12:35:30 -0500 (EST)
On Sat, 10 Jan 2004, [iso-8859-1] Nils O. Selåsdal wrote:
>
> In article <btn8v2$olk$1@daisy.noc.ucla.edu>, Digital Puer wrote:
> > I came across a question that asked for me to write a
> > small program that will compile in C but not in C++.
> > Any ideas?
> >
> > The only one I can think of is one that tries to
> > downcast a void * to a more specific pointer without
> > a cast:
> void foo(){
> unsigned char c = 0xfa;
> char *d = &c;
> }
This certainly *looks* like it would require a diagnostic in C,
as well as in C++. gcc and g++ agree with me; 'unsigned char *'
and 'char *' are not assignment-compatible.
> void foo(){
> char or[] = "or";
> }
This requires no diagnostic in either language. Maybe you're
thinking of
char *or = "or";
which is fine in C, but I'm not sure whether C++ still allows this
or not. (I'm guessing it does, for backwards compatibility, but I
could easily be wrong.)
-Arthur
- Next message: Richard Heathfield: "Re: program that compiles in C but not in C++?"
- Previous message: Nick Hounsome: "Re: how to call C++ from C?"
- In reply to: Nils O. Selåsdal: "Re: program that compiles in C but not in C++?"
- Next in thread: Richard Heathfield: "Re: program that compiles in C but not in C++?"
- Reply: Richard Heathfield: "Re: program that compiles in C but not in C++?"
- Reply: Nils O. Selåsdal: "Re: program that compiles in C but not in C++?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|