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++.beta - [bug] dmc.8.48.3 extern "C" and class member-functions

↑ ↓ ← Nic Tiger <g_tiger progtech.ru> writes:
Looks like bug: extern "C" is applied to class member-functions.
This code compiled without error with previous DMC (8.41.5n) and was 
taken from MS DX8 SDK (dxtrans.h)

If this is proper behavior (according to standards), I would like to 
hear suggestions how to work around this.

Nic Tiger


dmc -c dx.cpp >1
------------------
       DXBASESAMPLE(const DWORD val) { *this = (*(DXBASESAMPLE *)&val); }
                  ^
dx.cpp(19) : Error: '?0' is already defined
       operator DWORD () const {return *((DWORD *)this); }
              ^
dx.cpp(20) : Error: '?0' is already defined
--- errorlevel 1

------------------
extern "C"{
   typedef unsigned long DWORD;
   typedef unsigned char BYTE;

   class DXBASESAMPLE
   {
   public:
       BYTE Blue;
       BYTE Green;
       BYTE Red;
       BYTE Alpha;
       DXBASESAMPLE() {}
       DXBASESAMPLE(const BYTE alpha, const BYTE red, const BYTE green, 
const BYTE blue) :
           Alpha(alpha),
           Red(red),
           Green(green),
           Blue(blue) {}
       DXBASESAMPLE(const DWORD val) { *this = (*(DXBASESAMPLE *)&val); }
       operator DWORD () const {return *((DWORD *)this); }
       DWORD operator=(const DWORD val) { return *this = *((DXBASESAMPLE 
*)&val); }
   }; // DXBASESAMPLE
}
Apr 14 2006
↑ ↓ Walter Bright <newshound digitalmars.com> writes:
Nic Tiger wrote:
 Looks like bug: extern "C" is applied to class member-functions.
 This code compiled without error with previous DMC (8.41.5n) and was 
 taken from MS DX8 SDK (dxtrans.h)

The extern statements apply to everything inside them, including the class members. To not have them apply, move the class declaration outside the extern statement.
Apr 14 2006
↑ ↓ → Nic Tiger <g_tiger progtech.ru> writes:
Walter Bright wrote:
 Nic Tiger wrote:
 Looks like bug: extern "C" is applied to class member-functions.
 This code compiled without error with previous DMC (8.41.5n) and was 
 taken from MS DX8 SDK (dxtrans.h)

The extern statements apply to everything inside them, including the class members. To not have them apply, move the class declaration outside the extern statement.

too bad... because it is not my code, but Microsoft's :( will have to insert two lines, and maybe put all these headers under version control system to track changes. thanks for early reply!
Apr 14 2006