diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-01-29 09:42:59 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-01-29 09:42:59 +0000 |
| commit | c072867aaf9433ea128438db155fc148d3296b10 (patch) | |
| tree | 301de4d00559466d4ad32492ffc61cb612de8f91 /Primitives/interface | |
| parent | Fixed a number of minor issues (diff) | |
| download | DiligentCore-c072867aaf9433ea128438db155fc148d3296b10.tar.gz DiligentCore-c072867aaf9433ea128438db155fc148d3296b10.zip | |
Added API function call type specification to fix c/c++ mismatch on x86 MSVC
Diffstat (limited to 'Primitives/interface')
| -rw-r--r-- | Primitives/interface/CommonDefinitions.h | 7 | ||||
| -rw-r--r-- | Primitives/interface/DefineInterfaceHelperMacros.h | 4 | ||||
| -rw-r--r-- | Primitives/interface/Object.h | 8 |
3 files changed, 13 insertions, 6 deletions
diff --git a/Primitives/interface/CommonDefinitions.h b/Primitives/interface/CommonDefinitions.h index df62c08c..721e6ebb 100644 --- a/Primitives/interface/CommonDefinitions.h +++ b/Primitives/interface/CommonDefinitions.h @@ -38,6 +38,13 @@ # endif #endif +#ifdef _MSC_VER +// Note that MSVC x86 compiler by default uses __this call for class member functions +# define DILIGENT_CALL_TYPE __cdecl +#else +# define DILIGENT_CALL_TYPE +#endif + #if DILIGENT_C_INTERFACE # define DILIGENT_BEGIN_NAMESPACE(Name) diff --git a/Primitives/interface/DefineInterfaceHelperMacros.h b/Primitives/interface/DefineInterfaceHelperMacros.h index ecadc10a..2fd7b37a 100644 --- a/Primitives/interface/DefineInterfaceHelperMacros.h +++ b/Primitives/interface/DefineInterfaceHelperMacros.h @@ -55,7 +55,7 @@ # define CONST # define PURE # define REF * -# define METHOD(Name) (*Name) +# define METHOD(Name) (DILIGENT_CALL_TYPE * Name) // Suppose that DILIGENT_INTERFACE_NAME == Iface, then DILIGENT_END_INTERFACE macro below will expand to the following: // @@ -84,7 +84,7 @@ # define CONST const # define PURE = 0 # define REF & -# define METHOD(Name) Name +# define METHOD(Name) DILIGENT_CALL_TYPE Name # define DILIGENT_END_INTERFACE #endif diff --git a/Primitives/interface/Object.h b/Primitives/interface/Object.h index bda0d616..7721025f 100644 --- a/Primitives/interface/Object.h +++ b/Primitives/interface/Object.h @@ -47,7 +47,7 @@ struct IObject /// If the interface is not supported, null pointer will be returned. /// \remark The method increments the number of strong references by 1. The interface must be /// released by a call to Release() method when it is no longer needed. - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) = 0; + virtual void DILIGENT_CALL_TYPE QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) = 0; /// Increments the number of strong references by 1. @@ -57,7 +57,7 @@ struct IObject /// \return The number of strong references after incrementing the counter. /// \note In a multithreaded environment, the returned number may not be reliable /// as other threads may simultaneously change the actual value of the counter. - virtual ReferenceCounterValueType AddRef() = 0; + virtual ReferenceCounterValueType DILIGENT_CALL_TYPE AddRef() = 0; /// Decrements the number of strong references by 1 and destroys the object when the @@ -70,13 +70,13 @@ struct IObject /// as other threads may simultaneously change the actual value of the counter. /// The only reliable value is 0 as the object is destroyed when the last /// strong reference is released. - virtual ReferenceCounterValueType Release() = 0; + virtual ReferenceCounterValueType DILIGENT_CALL_TYPE Release() = 0; /// Returns the pointer to IReferenceCounters interface of the associated /// reference counters object. The method does *NOT* increment /// the number of strong references to the returned object. - virtual IReferenceCounters* GetReferenceCounters() const = 0; + virtual IReferenceCounters* DILIGENT_CALL_TYPE GetReferenceCounters() const = 0; }; #else |
