1*9356374aSAndroid Build Coastguard Worker // 2*9356374aSAndroid Build Coastguard Worker // Copyright 2019 The Abseil Authors. 3*9356374aSAndroid Build Coastguard Worker // 4*9356374aSAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License"); 5*9356374aSAndroid Build Coastguard Worker // you may not use this file except in compliance with the License. 6*9356374aSAndroid Build Coastguard Worker // You may obtain a copy of the License at 7*9356374aSAndroid Build Coastguard Worker // 8*9356374aSAndroid Build Coastguard Worker // https://www.apache.org/licenses/LICENSE-2.0 9*9356374aSAndroid Build Coastguard Worker // 10*9356374aSAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software 11*9356374aSAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS, 12*9356374aSAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*9356374aSAndroid Build Coastguard Worker // See the License for the specific language governing permissions and 14*9356374aSAndroid Build Coastguard Worker // limitations under the License. 15*9356374aSAndroid Build Coastguard Worker // 16*9356374aSAndroid Build Coastguard Worker // ----------------------------------------------------------------------------- 17*9356374aSAndroid Build Coastguard Worker // File: declare.h 18*9356374aSAndroid Build Coastguard Worker // ----------------------------------------------------------------------------- 19*9356374aSAndroid Build Coastguard Worker // 20*9356374aSAndroid Build Coastguard Worker // This file defines the ABSL_DECLARE_FLAG macro, allowing you to declare an 21*9356374aSAndroid Build Coastguard Worker // `absl::Flag` for use within a translation unit. You should place this 22*9356374aSAndroid Build Coastguard Worker // declaration within the header file associated with the .cc file that defines 23*9356374aSAndroid Build Coastguard Worker // and owns the `Flag`. 24*9356374aSAndroid Build Coastguard Worker 25*9356374aSAndroid Build Coastguard Worker #ifndef ABSL_FLAGS_DECLARE_H_ 26*9356374aSAndroid Build Coastguard Worker #define ABSL_FLAGS_DECLARE_H_ 27*9356374aSAndroid Build Coastguard Worker 28*9356374aSAndroid Build Coastguard Worker #include "absl/base/config.h" 29*9356374aSAndroid Build Coastguard Worker 30*9356374aSAndroid Build Coastguard Worker namespace absl { 31*9356374aSAndroid Build Coastguard Worker ABSL_NAMESPACE_BEGIN 32*9356374aSAndroid Build Coastguard Worker namespace flags_internal { 33*9356374aSAndroid Build Coastguard Worker 34*9356374aSAndroid Build Coastguard Worker // absl::Flag<T> represents a flag of type 'T' created by ABSL_FLAG. 35*9356374aSAndroid Build Coastguard Worker template <typename T> 36*9356374aSAndroid Build Coastguard Worker class Flag; 37*9356374aSAndroid Build Coastguard Worker 38*9356374aSAndroid Build Coastguard Worker } // namespace flags_internal 39*9356374aSAndroid Build Coastguard Worker 40*9356374aSAndroid Build Coastguard Worker // Flag 41*9356374aSAndroid Build Coastguard Worker // 42*9356374aSAndroid Build Coastguard Worker // Forward declaration of the `absl::Flag` type for use in defining the macro. 43*9356374aSAndroid Build Coastguard Worker template <typename T> 44*9356374aSAndroid Build Coastguard Worker using Flag = flags_internal::Flag<T>; 45*9356374aSAndroid Build Coastguard Worker 46*9356374aSAndroid Build Coastguard Worker ABSL_NAMESPACE_END 47*9356374aSAndroid Build Coastguard Worker } // namespace absl 48*9356374aSAndroid Build Coastguard Worker 49*9356374aSAndroid Build Coastguard Worker // ABSL_DECLARE_FLAG() 50*9356374aSAndroid Build Coastguard Worker // 51*9356374aSAndroid Build Coastguard Worker // This macro is a convenience for declaring use of an `absl::Flag` within a 52*9356374aSAndroid Build Coastguard Worker // translation unit. This macro should be used within a header file to 53*9356374aSAndroid Build Coastguard Worker // declare usage of the flag within any .cc file including that header file. 54*9356374aSAndroid Build Coastguard Worker // 55*9356374aSAndroid Build Coastguard Worker // The ABSL_DECLARE_FLAG(type, name) macro expands to: 56*9356374aSAndroid Build Coastguard Worker // 57*9356374aSAndroid Build Coastguard Worker // extern absl::Flag<type> FLAGS_name; 58*9356374aSAndroid Build Coastguard Worker #define ABSL_DECLARE_FLAG(type, name) ABSL_DECLARE_FLAG_INTERNAL(type, name) 59*9356374aSAndroid Build Coastguard Worker 60*9356374aSAndroid Build Coastguard Worker // Internal implementation of ABSL_DECLARE_FLAG to allow macro expansion of its 61*9356374aSAndroid Build Coastguard Worker // arguments. Clients must use ABSL_DECLARE_FLAG instead. 62*9356374aSAndroid Build Coastguard Worker #define ABSL_DECLARE_FLAG_INTERNAL(type, name) \ 63*9356374aSAndroid Build Coastguard Worker extern absl::Flag<type> FLAGS_##name; \ 64*9356374aSAndroid Build Coastguard Worker namespace absl /* block flags in namespaces */ {} \ 65*9356374aSAndroid Build Coastguard Worker /* second redeclaration is to allow applying attributes */ \ 66*9356374aSAndroid Build Coastguard Worker extern absl::Flag<type> FLAGS_##name 67*9356374aSAndroid Build Coastguard Worker 68*9356374aSAndroid Build Coastguard Worker #endif // ABSL_FLAGS_DECLARE_H_ 69