unique_identifier_name.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright Andrey Semashev 2007 - 2015.
  3. * Distributed under the Boost Software License, Version 1.0.
  4. * (See accompanying file LICENSE_1_0.txt or copy at
  5. * http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /*!
  8. * \file unique_identifier_name.hpp
  9. * \author Andrey Semashev
  10. * \date 30.04.2008
  11. *
  12. * The header contains \c BOOST_LOG_UNIQUE_IDENTIFIER_NAME macro definition.
  13. */
  14. #ifndef BOOST_LOG_UTILITY_UNIQUE_IDENTIFIER_NAME_HPP_INCLUDED_
  15. #define BOOST_LOG_UTILITY_UNIQUE_IDENTIFIER_NAME_HPP_INCLUDED_
  16. #include <boost/preprocessor/cat.hpp>
  17. #include <boost/log/detail/config.hpp>
  18. #ifdef BOOST_HAS_PRAGMA_ONCE
  19. #pragma once
  20. #endif
  21. #ifndef BOOST_LOG_DOXYGEN_PASS
  22. #define BOOST_LOG_UNIQUE_IDENTIFIER_NAME_INTERNAL_(prefix, postfix)\
  23. BOOST_PP_CAT(prefix, postfix)
  24. #define BOOST_LOG_UNIQUE_IDENTIFIER_NAME_INTERNAL(prefix, postfix)\
  25. BOOST_LOG_UNIQUE_IDENTIFIER_NAME_INTERNAL_(prefix, postfix)
  26. #endif // BOOST_LOG_DOXYGEN_PASS
  27. /*!
  28. * \def BOOST_LOG_UNIQUE_IDENTIFIER_NAME(prefix)
  29. *
  30. * Constructs a unique (in the current file scope) token that can be used as a variable name.
  31. * The name will contain a prefix passed in the \a prefix argument. This allows to use the
  32. * macro multiple times on a single line.
  33. */
  34. // In VC 7.0 and later when compiling with /ZI option __LINE__ macro is corrupted
  35. #ifdef BOOST_MSVC
  36. # define BOOST_LOG_UNIQUE_IDENTIFIER_NAME(prefix)\
  37. BOOST_LOG_UNIQUE_IDENTIFIER_NAME_INTERNAL(prefix, __COUNTER__)
  38. #else
  39. # define BOOST_LOG_UNIQUE_IDENTIFIER_NAME(prefix)\
  40. BOOST_LOG_UNIQUE_IDENTIFIER_NAME_INTERNAL(prefix, __LINE__)
  41. #endif // BOOST_MSVC
  42. #endif // BOOST_LOG_UTILITY_UNIQUE_IDENTIFIER_NAME_HPP_INCLUDED_