Article View: net.lang.c++
Article #322Re: C++ problems with DMD code
From: karl
Date: Mon, 22 Sep 1986 15:04
Date: Mon, 22 Sep 1986 15:04
24 lines
1747 bytes
1747 bytes
gaulke@uiucdcsp.CS.UIUC.EDU (Dave Gaulke) writes:
>I have found a problem with C++ when using it to write code for the DMD.
>The following is part of the output of the preprocessor when including the
>file <blit.h> for a simple program.
>
>typedef int (*ptr_fint)();
>main() { (*((int (*)())((ptr_fint *)0x0071d700)[ 43]))( 1 ); }
The problem is that "int (*)()" in oldC means "pointer to function returning
int" whereas in C++ it means "pointer to function taking no arguments and
returning int". "typedef int (*ptr_fint)(...);" is the correct declaration
in C++, and presumably there's a macro somewhere in blit.h that uses the
oldC cast "(int (*)())" which should be "(int (*)(...))" in C++.
The other compatibility problem which came up recently was a collision
between a structure tag and a variable (which share one namespace in C++).
Bjarne: is there a CC option that gives you compatibility with oldC in these
two cases? Also, ANSI C preserves the oldC meaning of "int (*)()" and adds
"int (*)(void)" for functions with no arguments. Will C++ switch to this
notation? Does it currently accept this notation?
Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint
Technical Details
Message-ID:
<165200004@haddock>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!think!ima!haddock!karlReferences:
<66700003@uiucdcsp>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!think!ima!haddock!karl From: karl@haddock Newsgroups: net.lang.c++ Subject: Re: C++ problems with DMD code Message-ID: <165200004@haddock> Date: Mon, 22-Sep-86 11:04:00 EDT Article-I.D.: haddock.165200004 Posted: Mon Sep 22 11:04:00 1986 Date-Received: Mon, 22-Sep-86 21:39:05 EDT References: <66700003@uiucdcsp> Lines: 24 Nf-ID: #R:uiucdcsp:66700003:haddock:165200004:000:1202 Nf-From: haddock!karl Sep 22 11:04:00 1986