2 // Copyright 2019 The Abseil Authors.
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // https://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
16 // -----------------------------------------------------------------------------
18 // -----------------------------------------------------------------------------
20 // This file defines the ABSL_DECLARE_FLAG macro, allowing you to declare an
21 // `absl::Flag` for use within a translation unit. You should place this
22 // declaration within the header file associated with the .cc file that defines
23 // and owns the `Flag`.
25 #ifndef ABSL_FLAGS_DECLARE_H_
26 #define ABSL_FLAGS_DECLARE_H_
28 #include "absl/strings/string_view.h"
31 namespace flags_internal {
33 // absl::Flag<T> represents a flag of type 'T' created by ABSL_FLAG.
37 } // namespace flags_internal
41 // Forward declaration of the `absl::Flag` type for use in defining the macro.
43 using Flag = flags_internal::Flag<T>;
47 // ABSL_DECLARE_FLAG()
49 // This macro is a convenience for declaring use of an `absl::Flag` within a
50 // translation unit. This macro should be used within a header file to
51 // declare usage of the flag within any .cc file including that header file.
53 // The ABSL_DECLARE_FLAG(type, name) macro expands to:
55 // extern absl::Flag<type> FLAGS_name;
56 #define ABSL_DECLARE_FLAG(type, name) extern ::absl::Flag<type> FLAGS_##name
58 #endif // ABSL_FLAGS_DECLARE_H_