www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Puzzling Digital Mars C++ Behavior

↑ ↓ ← Stephen Zamoscianyk <Stephen_member pathlink.com> writes:
Hello:

I discovered a behavior of the Digital Mars compiler that has me puzzled.
The small program reproduced below compiles without error as a .c program
but produces an error when compiled as a .cpp program, namely:

SC -cpp -r -Ae -Ar -Aa -mx -f -S -s -3 -a4 -c   -oFPTR2.obj FPTR2.cpp
int (*  t(int ix))(int *);
^
FPTR2.cpp(9) : Error: '(' expected following simple type name

The startling thing is that other compilers like DJ Delorie's DJGPP (ver 2.81),
Borland's BC++4.5 (bcc -ml -3 -k -N fptr2.cpp), and even (alas) Microsoft's
Visual C++ 4 compile this .cpp code without a complaint. I would be immensely
appreciative if you would clarify if this is some new C++ language behavior or
if this is some kind of bug.

Incidentally, replacing the declaration for the t-function with:
T  t(int ix);   //--FORWARD REFERENCE function prototype
where T is defined as:  typedef  int (*T)(int *k);
makes all the Digital Mars errors go away...

Thanks in advance for any assistance,

Stephen Zamoscianyk
byf9vh cs.com
Jul 30 2003
↑ ↓ → "Greg Peet" <admin gregpeet.com> writes:
doh! you forgot the source =)

"Stephen Zamoscianyk" <Stephen_member pathlink.com> wrote in message
news:bga4g8$2usm$1 digitaldaemon.com...
 Hello:

 I discovered a behavior of the Digital Mars compiler that has me puzzled.
 The small program reproduced below compiles without error as a .c program
 but produces an error when compiled as a .cpp program, namely:

 SC -cpp -r -Ae -Ar -Aa -mx -f -S -s -3 -a4 -c   -oFPTR2.obj FPTR2.cpp
 int (*  t(int ix))(int *);
 ^
 FPTR2.cpp(9) : Error: '(' expected following simple type name

 The startling thing is that other compilers like DJ Delorie's DJGPP (ver

 Borland's BC++4.5 (bcc -ml -3 -k -N fptr2.cpp), and even (alas)

 Visual C++ 4 compile this .cpp code without a complaint. I would be

 appreciative if you would clarify if this is some new C++ language

 if this is some kind of bug.

 Incidentally, replacing the declaration for the t-function with:
 T  t(int ix);   //--FORWARD REFERENCE function prototype
 where T is defined as:  typedef  int (*T)(int *k);
 makes all the Digital Mars errors go away...

 Thanks in advance for any assistance,

 Stephen Zamoscianyk
 byf9vh cs.com

Jul 30 2003