Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Commit e720ed4

Browse files
committed
renamed GOOGLE_GLOG_DLL_DECL to GLOG_EXPORT
Use a consistent naming and avoid platform specific terms. Also remove copy and paste code.
1 parent a8cfbe0 commit e720ed4

15 files changed

Lines changed: 108 additions & 262 deletions

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,8 @@ if (gflags_FOUND)
663663
endif (TARGET gflags::gflags)
664664
665665
target_compile_definitions (glog PRIVATE
666-
GFLAGS_DLL_DECLARE_FLAG=GOOGLE_GLOG_DLL_DECL
667-
GFLAGS_DLL_DEFINE_FLAG=GOOGLE_GLOG_DLL_DECL
666+
GFLAGS_DLL_DECLARE_FLAG=GLOG_EXPORT
667+
GFLAGS_DLL_DEFINE_FLAG=GLOG_EXPORT
668668
)
669669
endif (gflags_FOUND)
670670
@@ -711,7 +711,7 @@ target_compile_definitions (glogbase PUBLIC
711711
PRIVATE GOOGLE_GLOG_IS_A_DLL)
712712
713713
generate_export_header (glog
714-
EXPORT_MACRO_NAME GOOGLE_GLOG_DLL_DECL
714+
EXPORT_MACRO_NAME GLOG_EXPORT
715715
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/glog/export.h)
716716
717717
# Unit testing

bazel/glog.bzl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
7878
]
7979

8080
linux_or_darwin_copts = wasm_copts + [
81+
"-DGLOG_EXPORT=__attribute__((visibility(\\\"default\\\")))",
8182
# For src/utilities.cc.
8283
"-DHAVE_SYS_SYSCALL_H",
8384
# For src/logging.cc to create symlinks.
8485
"-DHAVE_UNISTD_H",
86+
"-fvisibility=hidden",
8587
]
8688

8789
freebsd_only_copts = [
@@ -97,6 +99,7 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
9799
]
98100

99101
windows_only_copts = [
102+
"-DGLOG_EXPORT=__declspec(dllexport)",
100103
"-DGLOG_NO_ABBREVIATED_SEVERITIES",
101104
"-DHAVE_SNPRINTF",
102105
"-I" + src_windows,
@@ -150,15 +153,16 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
150153
],
151154
strip_include_prefix = "src",
152155
defines = select({
153-
# GOOGLE_GLOG_DLL_DECL is normally set by export.h, but that's not
156+
# GLOG_EXPORT is normally set by export.h, but that's not
154157
# generated for Bazel.
155158
"@bazel_tools//src/conditions:windows": [
156-
"GOOGLE_GLOG_DLL_DECL=__declspec(dllexport)",
159+
"GLOG_EXPORT=",
157160
"GLOG_DEPRECATED=__declspec(deprecated)",
158161
"GLOG_NO_ABBREVIATED_SEVERITIES",
159162
],
160163
"//conditions:default": [
161164
"GLOG_DEPRECATED=__attribute__((deprecated))",
165+
"GLOG_EXPORT=__attribute__((visibility(\\\"default\\\")))",
162166
],
163167
}),
164168
copts =

src/base/commandlineflags.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@
6161

6262
#include <glog/logging.h>
6363

64-
#define DECLARE_VARIABLE(type, shorttype, name, tn) \
65-
namespace fL##shorttype { \
66-
extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name; \
67-
} \
64+
#define DECLARE_VARIABLE(type, shorttype, name, tn) \
65+
namespace fL##shorttype { \
66+
extern GLOG_EXPORT type FLAGS_##name; \
67+
} \
6868
using fL##shorttype::FLAGS_##name
69-
#define DEFINE_VARIABLE(type, shorttype, name, value, meaning, tn) \
70-
namespace fL##shorttype { \
71-
GOOGLE_GLOG_DLL_DECL type FLAGS_##name(value); \
72-
char FLAGS_no##name; \
73-
} \
69+
#define DEFINE_VARIABLE(type, shorttype, name, value, meaning, tn) \
70+
namespace fL##shorttype { \
71+
GLOG_EXPORT type FLAGS_##name(value); \
72+
char FLAGS_no##name; \
73+
} \
7474
using fL##shorttype::FLAGS_##name
7575

7676
// bool specialization
@@ -95,17 +95,17 @@
9595

9696
// Special case for string, because we have to specify the namespace
9797
// std::string, which doesn't play nicely with our FLAG__namespace hackery.
98-
#define DECLARE_string(name) \
99-
namespace fLS { \
100-
extern GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name; \
101-
} \
98+
#define DECLARE_string(name) \
99+
namespace fLS { \
100+
extern GLOG_EXPORT std::string& FLAGS_##name; \
101+
} \
102102
using fLS::FLAGS_##name
103-
#define DEFINE_string(name, value, meaning) \
104-
namespace fLS { \
105-
std::string FLAGS_##name##_buf(value); \
106-
GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name = FLAGS_##name##_buf; \
107-
char FLAGS_no##name; \
108-
} \
103+
#define DEFINE_string(name, value, meaning) \
104+
namespace fLS { \
105+
std::string FLAGS_##name##_buf(value); \
106+
GLOG_EXPORT std::string& FLAGS_##name = FLAGS_##name##_buf; \
107+
char FLAGS_no##name; \
108+
} \
109109
using fLS::FLAGS_##name
110110

111111
#endif // HAVE_LIB_GFLAGS

src/demangle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ _START_GOOGLE_NAMESPACE_
7878
// Demangle "mangled". On success, return true and write the
7979
// demangled symbol name to "out". Otherwise, return false.
8080
// "out" is modified even if demangling is unsuccessful.
81-
bool GOOGLE_GLOG_DLL_DECL Demangle(const char *mangled, char *out, size_t out_size);
81+
bool GLOG_EXPORT Demangle(const char *mangled, char *out, size_t out_size);
8282

8383
_END_GOOGLE_NAMESPACE_
8484

src/glog/log_severity.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,7 @@
4343
// whenever an ERROR occurs in production.
4444
// FATAL:
4545
// Use for undesired and unexpected events that the program cannot recover
46-
// from.
47-
48-
// Annoying stuff for windows -- makes sure clients can import these functions
49-
#ifndef GOOGLE_GLOG_DLL_DECL
50-
# if defined(_WIN32) && !defined(__CYGWIN__)
51-
# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
52-
# else
53-
# define GOOGLE_GLOG_DLL_DECL
54-
# endif
55-
#endif
46+
// from.
5647

5748
// Variables of type LogSeverity are widely taken to lie in the range
5849
// [0, NUM_SEVERITIES-1]. Be careful to preserve this assumption if
@@ -76,7 +67,7 @@ const int INFO = GLOG_INFO, WARNING = GLOG_WARNING,
7667
#define DFATAL_LEVEL FATAL
7768
#endif
7869

79-
extern GOOGLE_GLOG_DLL_DECL const char* const LogSeverityNames[NUM_SEVERITIES];
70+
extern GLOG_EXPORT const char* const LogSeverityNames[NUM_SEVERITIES];
8071

8172
// NDEBUG usage helpers related to (RAW_)DCHECK:
8273
//

0 commit comments

Comments
 (0)