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