You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When build a shared lib on windows you usually need a dllspec macro (like ABSL_CONSUME_DLL/ABSL_DLL), unfortunately the current MACRO implem of ABSL_DECLARE_FLAG() do not support this use case...
e.g. if we try to prepend the MACRO...
foo.h
#include"absl/flags/declare.h"
...
#if defined(_MSC_VER) && defined(FOO_BUILD_DLL)
// Annoying stuff for windows -- makes sure clients can import these functions
#if defined(FOO_EXPORT)
#defineFOO_DLL__declspec(dllexport)
#else
#defineFOO_DLL__declspec(dllimport)
#endif // defined(FOO_EXPORT)
#endif// _MSC_VER && FOO_BUILD_DLL
#ifndef FOO_DLL
#defineFOO_DLL
#endif
FOO_DLL ABSL_DECLARE_FLAG(bool, foo_bool);
FOO_DLL ABSL_DECLARE_FLAG(int, foo_int);
FOO_DLL ABSL_DECLARE_FLAG(int64_t, foo_long_int);
FOO_DLL ABSL_DECLARE_FLAG(std::string, foo_string);
Describe the issue
When build a shared lib on windows you usually need a dllspec macro (like
ABSL_CONSUME_DLL
/ABSL_DLL
), unfortunately the current MACRO implem ofABSL_DECLARE_FLAG()
do not support this use case...e.g. if we try to prepend the MACRO...
foo.h
with CMakeLists.txt:
and later in an app.exe's CMakeLists.txt
Since the
ABSL_DECLARE_FLAG_INTERNAL
implementation declares two time the flags (line 63 and 66)abseil-cpp/absl/flags/declare.h
Lines 62 to 66 in 0f102ad
we can't prepand with our
FOO_DLL
nor we can provide it to the macro...This regression aka double declaration has been introduced in:
1065514#diff-252f54025d208b3afe13aa8d62762bb88282ad00027be08396105994d31f813f
Steps to reproduce the problem
You have a complete working/borken example here. just test on windows with a cmake based build and play with the
#if 0/1
to enable my custom macro fix or show the issue...relevant src: https://github.com/Mizux/absl-cxx/blob/715fdb721515248b8b8c047325f78d46f7dfc0c8/foo/foo.hpp#L25-L41
On any windows git bash with MSVC and CMake installed.
Expected: compile + link ok
Observed:
if using
FOO_DLL ABSL_DECLARE_FLAG(...)
pathWhat version of Abseil are you using?
20240722.0
with a small patch to check c++ dialect detected IIRCpatch: https://github.com/Mizux/absl-cxx/blob/main/patches/abseil-cpp-20240722.0.patch
note: IIRC the patch was for debian where while we want to compile in C++17 absl figure out that the default compiler support c++20 and do not respect the CMAKE_CXX_STANDARD set before the FetchContent/MakeAvailable. Also a CMake version got a regression where
check_cxx_source_compiles
didn't capture the CMAKE_CXX_STANDARD....EDIT: seems related to https://gitlab.kitware.com/cmake/cmake/-/merge_requests/306
ref: https://github.com/Mizux/absl-cxx/blob/715fdb721515248b8b8c047325f78d46f7dfc0c8/cmake/dependencies/CMakeLists.txt#L40-L42
What operating system and version are you using?
MSVC Community 2022 (dllspec issue) gWindows cloudtop and windows 11 (X1 from re-stuff)
What compiler and version are you using?
msvc
What build system are you using?
CMake 3.29.5 (from VS Community 2022)
Additional context
the current workaround we use for
google/or-tools
is to define new MACROusage:
=> Would it be possible to add it to abseil-cpp directly ?
The text was updated successfully, but these errors were encountered: