'selectany' attribute is only valid on the initialization of global data with external linkage

686 views Asked by At

When I include <d3d11.h> file in Embarcadero RadStudio seattle 10 C++ IDE, compiler gives the following error:

[bcc64 Error] d3d11.h(9622): 'selectany' attribute is only valid on the initialization of global data with external linkage.

Please help me.

1

There are 1 answers

2
Remy Lebeau On

d3d11.h is a Microsoft header for Direct3D.

Microsoft's flavor of selectany differs slightly from Embarcadero's flavor of selectany.

In particular, Microsoft's flavor supports default-initialization of global object instances, whereas Embarcadero's does not. Globals must be initialized with data. d3d11.h (being a Microsoft header) is relying on Microsoft's selectany behavior. The variable in question (D3D11_VIDEO_DEFAULT) is not being initialized with any data, which is OK in Microsoft's compiler but is not OK in Embarcadero's compiler.

You would have to alter Embarcadero's copy of d3d11.h to add an initialization:

//extern const DECLSPEC_SELECTANY CD3D11_VIDEO_DEFAULT D3D11_VIDEO_DEFAULT;
extern const DECLSPEC_SELECTANY CD3D11_VIDEO_DEFAULT D3D11_VIDEO_DEFAULT = {};