Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: base/stringize_macros.h

Issue 5103001: Add shared macros for stringizing and converting ANSI string constants... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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 preprocessor macros for stringizing preprocessor
6 // symbols (or their output) and manipulating preprocessor symbols
7 // that define strings.
8
9 #ifndef BASE_STRINGIZE_MACROS_H_
10 #define BASE_STRINGIZE_MACROS_H_
11 #pragma once
12
13 // This is not very useful as it does not expand defined symbols if
14 // called directly. Use its counterpart without the _NO_EXPANSION
15 // suffix, below.
16 #define STRINGIZE_NO_EXPANSION(x) #x \
Evan Martin 2010/11/18 00:15:37 Unintentional trailing backslash (?)
Jói 2010/11/18 00:26:44 Whoops, removed.
17
18 // Use this to quote the provided parameter, first expanding it if it
19 // is a preprocessor symbol.
20 //
21 // For example, if:
22 // #define A FOO
23 // #define B(x) myobj->FunctionCall(x)
24 //
25 // Then:
26 // STRINGIZE(A) produces "FOO"
27 // STRINGIZE(B(y)) produces "myobj->FunctionCall(y)"
28 #define STRINGIZE(x) STRINGIZE_NO_EXPANSION(x)
29
30 // The following are defined only on Windows (for use when interacting
31 // with Windows APIs) as wide strings are otherwise deprecated.
32 #if defined(OS_WIN)
33
34 // Second-level utility macros to let us expand symbols.
35 #define LSTRINGIZE_NO_EXPANSION(x) L ## #x
36 #define TO_L_STRING_NO_EXPANSION(x) L ## x
37
38 // L version of STRINGIZE(). For examples above,
39 // LSTRINGIZE(A) produces L"FOO"
40 // LSTRINGIZE(B(y)) produces L"myobj->FunctionCall(y)"
41 #define LSTRINGIZE(x) LSTRINGIZE_NO_EXPANSION(x)
42
43 // Adds an L in front of an existing ASCII string constant (after
44 // expanding symbols). Does not do any quoting.
45 //
46 // For example, if:
47 // #define C "foo"
48 //
49 // Then:
50 // TO_L_STRING(C) produces L"foo"
51 #define TO_L_STRING(x) TO_L_STRING_NO_EXPANSION(x)
52
53 #endif // defined(OS_WIN)
54
55 #endif // BASE_STRINGIZE_MACROS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698