Wine's implementation of d3dtypes.h does not work with ISO C++

Daniel Scharrer dscharrer at gmail.com
Mon May 23 14:51:37 CDT 2011


Hi all,

I am working on porting the d3d 7 game Arx Fatalis [1] to linux/OpenGL
and we are currently compiling as a winelib application to do so.

Because the game is written in c++ and defines D3D_OVERLOADS, I get
the following errors in d3dtypes.h (reported as wine bug [2]):

/usr/include/wine/windows/d3dtypes.h: In member function ‘D3DVALUE&
_D3DMATRIX::operator()(int, int)’:
/usr/include/wine/windows/d3dtypes.h:339:30: error: ISO C++ forbids
casting to an array type ‘D3DVALUE [4][4]’
/usr/include/wine/windows/d3dtypes.h: In member function ‘const
D3DVALUE& _D3DMATRIX::operator()(int, int) const’:
/usr/include/wine/windows/d3dtypes.h:341:36: error: ISO C++ forbids
casting to an array type ‘const D3DVALUE [4][4]’

Notice that is is a fatal error and not just a warning unless
-fpermissive is passed to wineg++.

While we can work around this when using  gcc (using pragmas to enable
-fpermissive just for wine's d3d headers), there is no portable way
(across compilers) to use Direct3D's overloaded operators from wine's
implementation.

The bug report [2] hasn't gotten any real responses and I'd really
like to get this fixed, but don't know what the best solution would be
that follows wine coding conventions.

Wine's current implementation of D3DMATRIX is

typedef struct _D3DMATRIX {
  D3DVALUE        _11, _12, _13, _14;
  D3DVALUE        _21, _22, _23, _24;
  D3DVALUE        _31, _32, _33, _34;
  D3DVALUE        _41, _42, _43, _44;
#if defined(__cplusplus) && defined(D3D_OVERLOADS)
  _D3DMATRIX() { }

    /* This is different from MS, but avoids anonymous structs. */
    D3DVALUE &operator () (int r, int c)
	{ return ((D3DVALUE [4][4])&_11)[r][c]; }
    const D3DVALUE &operator() (int r, int c) const
	{ return ((const D3DVALUE [4][4])&_11)[r][c]; }
#endif
} D3DMATRIX, *LPD3DMATRIX;

MSDN doesn't seem to have a documentation for anything older than d3d
9 anymore, so I have no idea what the original definition looks like.

The comment indicates that anonymous structs aren't allowed -- is this correct?

An alternative solution would be to calculate the 2D array offsets
manually, something like this:
    D3DVALUE &operator () (int r, int c)
	{ return ((D3DVALUE*)&_11)[r*4 + c]; }
Would that implementation be acceptable?


Also, if D3D_OVERLOADS has been defined, wine's d3dtypes.h (and also
d3d.h) expect <math.h> to have already been included:

In file included from /usr/include/wine/windows/d3dtypes.h:346:0,
                 from /usr/include/wine/windows/d3d.h:26,
                 from test.cpp:4:
/usr/include/wine/windows/d3dvec.inl: In function ‘D3DVALUE
Magnitude(const _D3DVECTOR&)’:
/usr/include/wine/windows/d3dvec.inl:118:33: error: ‘sqrt’ was not
declared in this scope

As I don't have a copy of the d3d 7 SDK I can't check if this is
normal or another bug in the wine headers.

[1] https://github.com/lubosz/ArxFatalis
[2] http://bugs.winehq.org/show_bug.cgi?id=25942

--
Daniel Scharrer



More information about the wine-devel mailing list