c++.beta - [bug] dmc.8.48.3 extern "C" and class member-functions
- Nic Tiger (39/39) Apr 14 2006 Looks like bug: extern "C" is applied to class member-functions.
- Walter Bright (4/7) Apr 14 2006 The extern statements apply to everything inside them, including the
- Nic Tiger (6/14) Apr 14 2006 too bad...
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
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
Walter Bright wrote:Nic Tiger wrote: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!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