From 2c07bea7cb7e46d7d0b14e9da2ecc5499b66d7a8 Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Mon, 29 Apr 2024 21:59:12 +0800 Subject: [PATCH] fix __attribute__((constructor)) position --- 3party/gperftools/src/base/googleinit.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/3party/gperftools/src/base/googleinit.h b/3party/gperftools/src/base/googleinit.h index 50a1b22..d3fda39 100644 --- a/3party/gperftools/src/base/googleinit.h +++ b/3party/gperftools/src/base/googleinit.h @@ -61,13 +61,14 @@ private: #define REGISTER_MODULE_INITIALIZER(name, body) \ namespace { \ - __attribute__((constructor)) static void google_init_module_##name() { body; } \ + static void google_init_module_##name() { body; } \ GoogleInitializer google_initializer_module_##name(#name, google_init_module_##name, NULL); \ + __attribute__((constructor)) static void EnsureConstructorRunsBeforeMain() { google_init_module_##name().name(); } \ } #define REGISTER_MODULE_DESTRUCTOR(name, body) \ namespace { \ - __attribute__((constructor)) static void google_destruct_module_##name() { body; } \ + static void google_destruct_module_##name() { body; } \ GoogleInitializer google_destructor_module_##name(#name, NULL, google_destruct_module_##name); \ }