Crocoddyl
 
Loading...
Searching...
No Matches
deprecate.hpp
1
2// 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
14// https://blog.samat.io/2017/02/27/Deprecating-functions-and-methods-in-Cplusplus/
15// For C++14
16#if __cplusplus >= 201402L
17#if defined(__has_cpp_attribute)
18#if __has_cpp_attribute(deprecated)
19#define DEPRECATED(msg, func) [[deprecated(msg)]] func
20#endif
21#endif
22// For everyone else
23#else
24#ifdef __GNUC__
25#define DEPRECATED(msg, func) func __attribute__((deprecated(msg)))
26#elif defined(_MSC_VER)
27#define DEPRECATED(msg, func) __declspec(deprecated(msg)) func
28#endif
29#endif
30
31// For more details, visit
32// https://stackoverflow.com/questions/171435/portability-of-warning-preprocessor-directive
33// (copy paste from pinocchio/macros.hpp)
34#if defined(__GNUC__) || defined(__clang__)
35#define CROCODDYL_PRAGMA(x) _Pragma(#x)
36#define CROCODDYL_PRAGMA_MESSAGE(the_message) \
37 CROCODDYL_PRAGMA(GCC message #the_message)
38#define CROCODDYL_PRAGMA_WARNING(the_message) \
39 CROCODDYL_PRAGMA(GCC warning #the_message)
40#define CROCODDYL_PRAGMA_DEPRECATED(the_message) \
41 CROCODDYL_PRAGMA_WARNING(Deprecated : #the_message)
42
43#ifndef CROCODDYL_IGNORE_DEPRECATED_HEADER
44#define CROCODDYL_PRAGMA_DEPRECATED_HEADER(old_header, new_header) \
45 CROCODDYL_PRAGMA_WARNING( \
46 Deprecated header file : old_header has been replaced by \
47 new_header.\n Please use new_header instead of old_header.)
48#else
49#define CROCODDYL_PRAGMA_DEPRECATED_HEADER(old_header, new_header)
50#endif // CROCODDYL_IGNORE_DEPRECATED_HEADER
51
52#ifndef CROCODDYL_IGNORE_DEPRECATED_HEADER
53#define CROCODDYL_PRAGMA_TO_BE_REMOVED_HEADER(remove_header) \
54 CROCODDYL_PRAGMA_WARNING( \
55 Deprecated header file : remove_header has now been \
56 deprecated.\n It would be removed in the upcoming releases.)
57#else
58#define CROCODDYL_PRAGMA_TO_BE_REMOVED_HEADER(remove_header)
59#endif // CROCODDYL_IGNORE_TO_BE_REMOVED_HEADER
60
61#endif // defined(__GNUC__) || defined(__clang__
62#endif // CROCODDYL_CORE_UTILS_DEPRECATE_HPP_