@@ -329,23 +329,39 @@ _bson_assert_failed_on_param (const char *param, const char *func)
329
329
#define BSON_TYPEOF typeof
330
330
#endif
331
331
332
+ /* *
333
+ * @brief Statically annotate an entity as deprecated, including the given deprecation message
334
+ *
335
+ * @param Message The message to be included in a deprecation warning. This
336
+ * should be a string literal.
337
+ */
338
+ #define BSON_DEPRECATED (Message ) _bsonDeprecatedImpl (Message)
332
339
333
- #if BSON_GNUC_CHECK_VERSION(3, 1)
334
- #define BSON_GNUC_DEPRECATED __attribute__ ((__deprecated__))
340
+ // Pick the appropriate implementation of a deprecation attribute
341
+ #if defined(_MSC_VER)
342
+ // For MSVC, emit __declspec(deprecated(Msg))
343
+ #define _bsonDeprecatedImpl (Msg ) __declspec (deprecated (Msg))
344
+ #elif defined(__GNUC__) && (defined(__clang__) || BSON_GNUC_CHECK_VERSION(4, 5))
345
+ // For new enough Clang and GCC, emit __attribute__((__deprecated__(Msg)))
346
+ #define _bsonDeprecatedImpl (Msg ) __attribute__ ((__deprecated__ (Msg)))
347
+ #elif defined(__GNUC__)
348
+ // For older GCC, emit deprecation attribute without the message
349
+ #define _bsonDeprecatedImpl (Msg ) __attribute__ ((__deprecated__))
335
350
#else
336
- #define BSON_GNUC_DEPRECATED
351
+ // For other compilers, emit nothing
352
+ #define _bsonDeprecatedImpl (Msg )
337
353
#endif
338
354
355
+ #define BSON_DEPRECATED_FOR (F ) BSON_DEPRECATED (" This API is deprecated. Use " #F " instead." )
356
+
357
+ #define BSON_GNUC_DEPRECATED BSON_DEPRECATED (" This API is deprecated" )
358
+ #define BSON_GNUC_DEPRECATED_FOR (F ) BSON_DEPRECATED_FOR (F)
359
+
339
360
#define BSON_CONCAT_IMPL (a, ...) a##__VA_ARGS__
340
361
#define BSON_CONCAT (a, ...) BSON_CONCAT_IMPL (a, __VA_ARGS__)
341
362
#define BSON_CONCAT3 (a, b, c ) BSON_CONCAT (a, BSON_CONCAT (b, c))
342
363
#define BSON_CONCAT4 (a, b, c, d ) BSON_CONCAT (BSON_CONCAT (a, b), BSON_CONCAT (c, d))
343
364
344
- #if BSON_GNUC_CHECK_VERSION(4, 5)
345
- #define BSON_GNUC_DEPRECATED_FOR (f ) __attribute__ ((deprecated (" Use " #f " instead" )))
346
- #else
347
- #define BSON_GNUC_DEPRECATED_FOR (f ) BSON_GNUC_DEPRECATED
348
- #endif
349
365
350
366
/* *
351
367
* @brief String-ify the given argument
0 commit comments