crocoddyl  1.8.1
Contact RObot COntrol by Differential DYnamic programming Library (Crocoddyl)
deprecate.hpp
1 // BSD 3-Clause License
3 //
4 // Copyright (C) 2020-2021, University of Edinburgh, CNRS, INRIA
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
8 
9 #ifndef CROCODDYL_CORE_UTILS_DEPRECATE_HPP_
10 #define CROCODDYL_CORE_UTILS_DEPRECATE_HPP_
11 
12 // Helper to deprecate functions and methods
13 // See https://blog.samat.io/2017/02/27/Deprecating-functions-and-methods-in-Cplusplus/
14 // For C++14
15 #if __cplusplus >= 201402L
16 #if defined(__has_cpp_attribute)
17 #if __has_cpp_attribute(deprecated)
18 #define DEPRECATED(msg, func) [[deprecated(msg)]] func
19 #endif
20 #endif
21 // For everyone else
22 #else
23 #ifdef __GNUC__
24 #define DEPRECATED(msg, func) func __attribute__((deprecated(msg)))
25 #elif defined(_MSC_VER)
26 #define DEPRECATED(msg, func) __declspec(deprecated(msg)) func
27 #endif
28 #endif
29 
30 // For more details, visit https://stackoverflow.com/questions/171435/portability-of-warning-preprocessor-directive
31 // (copy paste from pinocchio/macros.hpp)
32 #if defined(__GNUC__) || defined(__clang__)
33 #define CROCODDYL_PRAGMA(x) _Pragma(#x)
34 #define CROCODDYL_PRAGMA_MESSAGE(the_message) CROCODDYL_PRAGMA(GCC message #the_message)
35 #define CROCODDYL_PRAGMA_WARNING(the_message) CROCODDYL_PRAGMA(GCC warning #the_message)
36 #define CROCODDYL_PRAGMA_DEPRECATED(the_message) CROCODDYL_PRAGMA_WARNING(Deprecated : #the_message)
37 
38 #ifndef CROCODDYL_IGNORE_DEPRECATED_HEADER
39 #define CROCODDYL_PRAGMA_DEPRECATED_HEADER(old_header, new_header) \
40  CROCODDYL_PRAGMA_WARNING( \
41  Deprecated header file \
42  : old_header has been replaced by new_header.\n Please use new_header instead of old_header.)
43 #else
44 #define CROCODDYL_PRAGMA_DEPRECATED_HEADER(old_header, new_header)
45 #endif // CROCODDYL_IGNORE_DEPRECATED_HEADER
46 
47 #ifndef CROCODDYL_IGNORE_DEPRECATED_HEADER
48 #define CROCODDYL_PRAGMA_TO_BE_REMOVED_HEADER(remove_header) \
49  CROCODDYL_PRAGMA_WARNING(Deprecated header file \
50  : remove_header has now been deprecated.\n It would be removed in the upcoming releases.)
51 #else
52 #define CROCODDYL_PRAGMA_TO_BE_REMOVED_HEADER(remove_header)
53 #endif // CROCODDYL_IGNORE_TO_BE_REMOVED_HEADER
54 
55 #endif // defined(__GNUC__) || defined(__clang__
56 #endif // CROCODDYL_CORE_UTILS_DEPRECATE_HPP_