OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
Mark Mentovai
2015/11/19 21:52:55
If this defines BUILDFLAG() as the primary macro,
Mark Mentovai
2015/11/19 21:53:26
In the CL description, capitalize Google Now, beca
brettw
2015/11/20 00:02:37
It defines BUILDFLAG and BUILDVAR, and I was gener
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BASE_BUILD_HEADER_H_ | |
Mark Mentovai
2015/11/19 21:52:55
BUILD_BUILD_HEADER_H_ here and in two other places
| |
6 #define BASE_BUILD_HEADER_H_ | |
7 | |
8 // These macros un-mangle the names of the build flags in a way that looks | |
9 // natural, and gives errors if the flag is not defined. Normally in the | |
10 // preprocessor it's easy to make mistakes that interpret "you haven't done | |
11 // the setup to know what the flag is" as "flag is off". | |
12 // | |
13 // This is for use with headers generated by write_build_header.py. | |
14 | |
15 #define BUILDFLAG_CAT(a, b) a ## b | |
16 #define BUILDFLAG_CAT2(a, b) BUILDFLAG_CAT(a, b) | |
Mark Mentovai
2015/11/19 21:52:55
I recognize this pattern (although I doubt most de
brettw
2015/11/20 00:02:37
This stuff is all removed now. Yay!
| |
17 | |
18 // These allow the code below to have an expression evaluate to 1 if the value | |
19 // is 0 or 1, and 0 if it's undefined or a different value. | |
20 #define BUILDFLAG_DEFINE_CHECK_0 1 | |
21 #define BUILDFLAG_DEFINE_CHECK_1 1 | |
22 | |
23 // Accessor for boolean values. Throws an error if undefined. Since the | |
Mark Mentovai
2015/11/19 21:52:55
“if flag is undefined”
| |
24 // invocation of a #define can't normally throw an error, emulate that by | |
Mark Mentovai
2015/11/19 21:52:55
of a macro
| |
25 // forcing a divide-by-0 in the preprocessor. | |
26 #define BUILDFLAG(flag) (BUILDFLAG_CAT2(BUILDFLAG_FLAG_VALUE_, flag) / BUILDFLAG _CAT2(BUILDFLAG_DEFINE_CHECK_, BUILDFLAG_CAT2(BUILDFLAG_FLAG_VALUE_, flag))) // If you see a division by 0 it means your flag is undefined and you're missing t he header. | |
Mark Mentovai
2015/11/19 21:52:55
I believe that this can be simplified by using def
Mark Mentovai
2015/11/19 21:52:55
Can we name this CR_BUILDFLAG to provide some semb
brettw
2015/11/20 00:02:37
I thought about CR_* and decided against it. I can
brettw
2015/11/20 00:02:37
This works. I like your way.
brettw
2015/11/20 04:10:39
Scratch that, Visual Studio doesn't like this. I s
spang
2015/11/20 19:00:24
Was
#if BUILDFLAG_ENABLE_FOO()
considered? It's
| |
27 | |
28 // For flags where you need to know the value. | |
29 #define BUILDVAR(var) (BUILDFLAG_VAR_VALUE_##var) | |
Mark Mentovai
2015/11/19 21:52:55
Having both BUILDFLAG_FLAG_VALUE_* and BUILDFLAG_V
| |
30 | |
31 #endif // BASE_BUILD_HEADER_H_ | |
Mark Mentovai
2015/11/19 21:52:55
After I read this file, I saw that you had more do
| |
OLD | NEW |