OLD | NEW |
(Empty) | |
| 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 utility preprocessor macros. |
| 6 |
| 7 #ifndef BASE_PREPROCESSOR_UTIL_H_ |
| 8 #define BASE_PREPROCESSOR_UTIL_H_ |
| 9 #pragma once |
| 10 |
| 11 // These are not very useful; they do not expand defined symbols if |
| 12 // called directly. Use their counterparts without the _NO_EXPANSION |
| 13 // suffix, below. |
| 14 #define STRINGIZE_NO_EXPANSION(x) #x |
| 15 #define LSTRINGIZE_NO_EXPANSION(x) L ## #x |
| 16 #define TO_L_STRING_NO_EXPANSION(x) L ## x |
| 17 |
| 18 // Use these to quote the provided parameter, first expanding it if it |
| 19 // is a preprocessor symbol. The L version quotes it as a wide string, |
| 20 // the non-L version as an ANSI string. |
| 21 // |
| 22 // For example, if: |
| 23 // #define A FOO |
| 24 // #define B(x) myobj->FunctionCall(x) |
| 25 // |
| 26 // Then: |
| 27 // STRINGIZE(A) produces "FOO" |
| 28 // LSTRINGIZE(B(y)) produces L"myobj->FunctionCall(y)" |
| 29 #define STRINGIZE(x) STRINGIZE_NO_EXPANSION(x) |
| 30 #define LSTRINGIZE(x) LSTRINGIZE_NO_EXPANSION(x) |
| 31 |
| 32 // Adds an L in front of an existing ANSI string constant (after |
| 33 // expanding symbols). Does not do any quoting. |
| 34 // |
| 35 // For example, if: |
| 36 // #define C "foo" |
| 37 // |
| 38 // Then: |
| 39 // TO_L_STRING(C) produces L"foo" |
| 40 #define TO_L_STRING(x) TO_L_STRING_NO_EXPANSION(x) |
| 41 |
| 42 #endif // BASE_PREPROCESSOR_UTIL_H_ |
OLD | NEW |