stringize_macros.h 1014 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright (c) 2010 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. //
  5. // This file defines preprocessor macros for stringizing preprocessor
  6. // symbols (or their output) and manipulating preprocessor symbols
  7. // that define strings.
  8. #ifndef BASE_STRINGS_STRINGIZE_MACROS_H_
  9. #define BASE_STRINGS_STRINGIZE_MACROS_H_
  10. #include "build/build_config.h"
  11. // This is not very useful as it does not expand defined symbols if
  12. // called directly. Use its counterpart without the _NO_EXPANSION
  13. // suffix, below.
  14. #define STRINGIZE_NO_EXPANSION(x) #x
  15. // Use this to quote the provided parameter, first expanding it if it
  16. // is a preprocessor symbol.
  17. //
  18. // For example, if:
  19. // #define A FOO
  20. // #define B(x) myobj->FunctionCall(x)
  21. //
  22. // Then:
  23. // STRINGIZE(A) produces "FOO"
  24. // STRINGIZE(B(y)) produces "myobj->FunctionCall(y)"
  25. #define STRINGIZE(x) STRINGIZE_NO_EXPANSION(x)
  26. #endif // BASE_STRINGS_STRINGIZE_MACROS_H_