Ask Your Question
0

Errors in directx.hpp 3.0 Dev

asked 2015-12-10 06:48:56 -0500

Boogaloo gravatar image

updated 2015-12-10 08:07:59 -0500

boaz001 gravatar image

In the header there are 3 tests for __d3d11_h__ and 10 and 9 versions, but the tests only include the structures if these are NOT defined!

#if !defined(__d3d11_h__)
struct ID3D11Device;
...

Shouldn't the negate be removed, so:-

#if defined(__d3d11_h__)
struct ID3D11Device;
...
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-12-10 08:09:53 -0500

boaz001 gravatar image

No, it shouldn't.

It does not include the structures, only declares it. And it probably does it this way so it can compile even if no DirectX header is available.

edit flag offensive delete link more

Comments

If no declarations are made, all structures are available, however, if someone declairs __d3d11_h__ them DX11 is excluded, but DX9 and 10 are available.

Sort of weird logic if you ask me!

Boogaloo gravatar imageBoogaloo ( 2015-12-10 09:43:07 -0500 )edit

But that 'someone' is going to be the header that defines that struct ID3D11Device, it should never be defined by your own code. This is merely a interface class it doesn't know anything about the types. That is why it only declares it, but does not define it difference. It trusts the header that has __d3d11_h__ defined to also declare the struct ID3D11Device. You also might want to google this to see how that works.

boaz001 gravatar imageboaz001 ( 2015-12-11 03:21:31 -0500 )edit

I do no understand you: can you explain why the controls exists in the first place, as all they do is allow selective removal of the structures, rather than the usual case of controls enabling things.

Boogaloo gravatar imageBoogaloo ( 2015-12-11 03:49:53 -0500 )edit

I don't understand what you don't understand;). Without this control there would be multiple declaration's of the struct. That does not necessarily hurt, but this way you give the header the full responsibility to declare (and define) the struct. In my opinion this is just another case of enabling 'things', in this case it is the not needing to declare a struct again... nothing special going on.

boaz001 gravatar imageboaz001 ( 2015-12-11 04:43:18 -0500 )edit

Did you look at the header? All three version of the struct are declared if none of the __D3D... are defined.

The structures are ONLY REMOVED when someone defines the __D3D...

I would expect to have to define what I want to use, to use it, not define what I don't want.

Boogaloo gravatar imageBoogaloo ( 2015-12-11 09:13:04 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-12-10 06:48:56 -0500

Seen: 30 times

Last updated: Dec 10 '15