cppassert.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /****************************************************************************
  2. * **
  3. * ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
  4. * ** Contact: http://www.qt-project.org/legal
  5. * **
  6. * ** This file is part of Qt Creator.
  7. * **
  8. * ** Commercial License Usage
  9. * ** Licensees holding valid commercial Qt licenses may use this file in
  10. * ** accordance with the commercial license agreement provided with the
  11. * ** Software or, alternatively, in accordance with the terms contained in
  12. * ** a written agreement between you and Digia. For licensing terms and
  13. * ** conditions see http://www.qt.io/licensing. For further information
  14. * ** use the contact form at http://www.qt.io/contact-us.
  15. * **
  16. * ** GNU Lesser General Public License Usage
  17. * ** Alternatively, this file may be used under the terms of the GNU Lesser
  18. * ** General Public License version 2.1 or version 3 as published by the Free
  19. * ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
  20. * ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
  21. * ** following information to ensure the GNU Lesser General Public License
  22. * ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
  23. ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  24. * **
  25. * ** In addition, as a special exception, Digia gives you certain additional
  26. * ** rights. These rights are described in the Digia Qt LGPL Exception
  27. * ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  28. * **
  29. * ****************************************************************************/
  30. #ifndef SOFT_ASSERT_H
  31. #define SOFT_ASSERT_H
  32. #include <iostream>
  33. #define CPP_ASSERT_STRINGIFY_HELPER(x) #x
  34. #define CPP_ASSERT_STRINGIFY(x) CPP_ASSERT_STRINGIFY_HELPER(x)
  35. #define CPP_ASSERT_STRING(cond) std::cerr \
  36. << "SOFT ASSERT: \"" cond"\" in file " __FILE__ ", line " CPP_ASSERT_STRINGIFY(__LINE__) \
  37. << std::endl;
  38. #define CPP_ASSERT(cond, action) if (cond) {} else { CPP_ASSERT_STRING(#cond); action; } do {} while (0)
  39. #define CPP_CHECK(cond) if (cond) {} else { CPP_ASSERT_STRING(#cond); } do {} while (0)
  40. #endif // SOFT_ASSERT_H