Houdini Engine 3.2
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
HAPI_API.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * COMMENTS:
7  */
8 
9 #ifndef __HAPI_API_h__
10 #define __HAPI_API_h__
11 
12 // Helper macros.
13 #if defined( __GNUC__ )
14  #define HAPI_IS_GCC_GE( MAJOR, MINOR ) \
15  ( __GNUC__ > MAJOR || (__GNUC__ == MAJOR && __GNUC_MINOR__ >= MINOR) )
16 #else
17  #define HAPI_IS_GCC_GE( MAJOR, MINOR ) 0
18 #endif // defined( __GNUC__ )
19 #define HAPI_TO_STRING_( a ) # a
20 #define HAPI_TO_STRING( a ) HAPI_TO_STRING_( a )
21 
22 // Mark function as deprecated and may be removed in the future.
23 // @note This qualifier can only appear in function declarations.
24 #ifdef HAPI_SUPPRESS_DEPRECATIONS
25  #define HAPI_DEPRECATED( hapi_ver, houdini_ver )
26  #define HAPI_DEPRECATED_REPLACE( hapi_ver, houdini_ver, replacement )
27 #elif defined( GCC3 )
28  #if HAPI_IS_GCC_GE( 4, 6 ) || defined( __clang__ )
29  #define HAPI_DEPRECATED( hapi_ver, houdini_ver ) \
30  __attribute__( ( deprecated( \
31  "Deprecated since version HAPI " HAPI_TO_STRING( hapi_ver ) \
32  ", Houdini " HAPI_TO_STRING( houdini_ver ) ) ) )
33  #define HAPI_DEPRECATED_REPLACE( hapi_ver, houdini_ver, replacement ) \
34  __attribute__( ( deprecated( \
35  "Deprecated since version HAPI " HAPI_TO_STRING( hapi_ver ) \
36  ", Houdini " HAPI_TO_STRING( houdini_ver ) ". Use " \
37  HAPI_TO_STRING( replacement ) " instead." ) ) )
38  #else
39  #define HAPI_DEPRECATED( hapi_ver, houdini_ver ) \
40  __attribute__( ( deprecated ) )
41  #define HAPI_DEPRECATED_REPLACE( hapi_ver, houdini_ver, replacement ) \
42  __attribute__( ( deprecated ) )
43  #endif
44 #elif defined( _MSC_VER )
45  #define HAPI_DEPRECATED( hapi_ver, houdini_ver ) \
46  __declspec( deprecated( \
47  "Deprecated since version HAPI " HAPI_TO_STRING( hapi_ver ) \
48  ", Houdini " HAPI_TO_STRING( houdini_ver ) ) )
49  #define HAPI_DEPRECATED_REPLACE( hapi_ver, houdini_ver, replacement ) \
50  __declspec( deprecated( \
51  "Deprecated since version HAPI " HAPI_TO_STRING( hapi_ver ) \
52  ", Houdini " HAPI_TO_STRING( houdini_ver ) ". Use " \
53  HAPI_TO_STRING( replacement ) " instead." ) )
54 #else
55  #define HAPI_DEPRECATED( hapi_ver, houdini_ver )
56  #define HAPI_DEPRECATED_REPLACE( hapi_ver, houdini_ver, replacement )
57 #endif
58 
59 #if defined( WIN32 ) && !defined( MAKING_STATIC )
60  #define HAPI_VISIBILITY_EXPORT __declspec( dllexport )
61  #define HAPI_VISIBILITY_IMPORT __declspec( dllimport )
62  #define HAPI_VISIBILITY_EXPORT_TINST HAPI_VISIBILITY_EXPORT
63  #define HAPI_VISIBILITY_IMPORT_TINST HAPI_VISIBILITY_IMPORT
64 #elif defined(__GNUC__) && HAPI_IS_GCC_GE( 4, 2 ) && !defined( MAKING_STATIC )
65  #define HAPI_VISIBILITY_EXPORT __attribute__( ( visibility( "default" ) ) )
66  #define HAPI_VISIBILITY_IMPORT __attribute__( ( visibility( "default" ) ) )
67  #define HAPI_VISIBILITY_EXPORT_TINST
68  #define HAPI_VISIBILITY_IMPORT_TINST
69 #else
70  #define HAPI_VISIBILITY_EXPORT
71  #define HAPI_VISIBILITY_IMPORT
72  #define HAPI_VISIBILITY_EXPORT_TINST
73  #define HAPI_VISIBILITY_IMPORT_TINST
74 #endif
75 
76 #ifdef HAPI_EXPORTS
77  #define HAPI_API HAPI_VISIBILITY_EXPORT
78 #else
79  #define HAPI_API HAPI_VISIBILITY_IMPORT
80 #endif // HAPI_EXPORTS
81 
82 #if defined( WIN32 )
83  #define HAPI_CALL __cdecl
84 #else
85  #define HAPI_CALL
86 #endif // defined( WIN32 )
87 
88 #ifdef __cplusplus
89  #define HAPI_EXTERN_C extern "C"
90 #else
91  #define HAPI_EXTERN_C
92 #endif // __cplusplus
93 
94 #define HAPI_RETURN HAPI_Result HAPI_CALL
95 
96 #define HAPI_DECL_RETURN( r ) HAPI_EXTERN_C HAPI_API r HAPI_CALL
97 #define HAPI_DECL_DEPRECATED( hapi_ver, houdini_ver ) \
98  HAPI_EXTERN_C \
99  HAPI_DEPRECATED( hapi_ver, houdini_ver ) \
100  HAPI_API \
101  HAPI_RETURN
102 #define HAPI_DECL_DEPRECATED_REPLACE( hapi_ver, houdini_ver, replacement ) \
103  HAPI_EXTERN_C \
104  HAPI_DEPRECATED_REPLACE( hapi_ver, houdini_ver, replacement ) \
105  HAPI_API \
106  HAPI_RETURN
107 
108 #define HAPI_DECL HAPI_EXTERN_C HAPI_API HAPI_RETURN
109 #define HAPI_DEF HAPI_EXTERN_C HAPI_RETURN
110 
111 // Static asserts
112 #ifdef __cplusplus
113 #define HAPI_STATIC_ASSERT( cond, msg ) \
114  template< bool b > \
115  struct HAPI_StaticAssert_##msg {}; \
116  template<> \
117  struct HAPI_StaticAssert_##msg< true > \
118  { \
119  typedef int static_assert_##msg; \
120  }; \
121  typedef HAPI_StaticAssert_##msg< ( cond ) >::static_assert_##msg _sa
122 #else
123  #define HAPI_STATIC_ASSERT( cond, msg ) HAPI_STATIC_ASSERT_I( cond, msg )
124  #define HAPI_STATIC_ASSERT_I( cond, msg ) \
125  typedef char static_assert_##msg[ 2 * ( cond ) - 1 ]
126 #endif // __cplusplus
127 
128 #endif // __HAPI_API_h__