Skip to content

Commit

Permalink
Fix annoying warnings on MSVC latest.
Browse files Browse the repository at this point in the history
Fix link test failure on MSVC.
  • Loading branch information
ned14 committed Nov 21, 2024
1 parent 83e5127 commit 72ff7b1
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
9 changes: 9 additions & 0 deletions include/outcome/basic_outcome.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ Distributed under the Boost Software License, Version 1.0.
#pragma clang diagnostic ignored "-Wdocumentation" // Standardese markup confuses clang
#endif

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable : 6287) // redundant code
#endif

OUTCOME_V2_NAMESPACE_EXPORT_BEGIN

template <class R, class S, class P, class NoValuePolicy> //
Expand Down Expand Up @@ -1139,6 +1144,10 @@ SIGNATURE NOT RECOGNISED

OUTCOME_V2_NAMESPACE_END

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif

#ifdef __clang__
#pragma clang diagnostic pop
#endif
Expand Down
9 changes: 9 additions & 0 deletions include/outcome/basic_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ Distributed under the Boost Software License, Version 1.0.
#pragma clang diagnostic ignored "-Wdocumentation" // Standardese markup confuses clang
#endif

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable: 6287) // redundant code
#endif

OUTCOME_V2_NAMESPACE_EXPORT_BEGIN

template <class R, class S, class NoValuePolicy> //
Expand Down Expand Up @@ -755,6 +760,10 @@ static_assert(std::is_standard_layout<basic_result<int, long, policy::all_narrow

OUTCOME_V2_NAMESPACE_END

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif

#ifdef __clang__
#pragma clang diagnostic pop
#endif
Expand Down
6 changes: 3 additions & 3 deletions include/outcome/detail/revision.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ Distributed under the Boost Software License, Version 1.0.
*/

// Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time
#define OUTCOME_PREVIOUS_COMMIT_REF 954a054e50f2f121703a65aa6173a5d4f9748375
#define OUTCOME_PREVIOUS_COMMIT_DATE "2024-11-10 23:34:00 +00:00"
#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 954a054e
#define OUTCOME_PREVIOUS_COMMIT_REF 83e5127dd20b15e3f59059e5862e9926283fee80
#define OUTCOME_PREVIOUS_COMMIT_DATE "2024-11-21 14:05:57 +00:00"
#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 83e5127d
10 changes: 5 additions & 5 deletions include/outcome/experimental/result.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ extern "C"

extern OUTCOME_C_WEAK void outcome_make_result_status_code_failure_posix(void *out, size_t bytes, size_t offset, int errcode);
extern OUTCOME_C_WEAK void outcome_make_result_status_code_failure_system(void *out, size_t bytes, size_t offset, intptr_t errcode);
extern int outcome_status_code_equal(const void *a, const void *b);
extern int outcome_status_code_equal_generic(const void *a, int errcode);
extern const char *outcome_status_code_message(const void *a);
extern OUTCOME_C_WEAK int outcome_status_code_equal(const void *a, const void *b);
extern OUTCOME_C_WEAK int outcome_status_code_equal_generic(const void *a, int errcode);
extern OUTCOME_C_WEAK const char *outcome_status_code_message(const void *a);


#ifdef __cplusplus
Expand Down Expand Up @@ -188,15 +188,15 @@ extern "C"
OUTCOME_C_NODISCARD_EXTERN_C OUTCOME_C_WEAK struct cxx_result_status_code_##ident outcome_make_result_##ident##_failure_posix(int errcode) \
{ \
struct cxx_result_status_code_##ident ret; \
assert(outcome_make_result_status_code_failure_posix); /* If this fails, you need to compile this file at least once in C++. */ \
assert(outcome_make_result_status_code_failure_posix!=NULL); /* If this fails, you need to compile this file at least once in C++. */ \
outcome_make_result_status_code_failure_posix((void *) &ret, sizeof(ret), offsetof(struct cxx_result_status_code_##ident, flags), errcode); \
return ret; \
} \
OUTCOME_C_MSVC_FORCE_EMIT(outcome_make_result_##ident##_failure_posix) \
OUTCOME_C_NODISCARD_EXTERN_C OUTCOME_C_WEAK struct cxx_result_status_code_##ident outcome_make_result_##ident##_failure_system(intptr_t errcode) \
{ \
struct cxx_result_status_code_##ident ret; \
assert(outcome_make_result_status_code_failure_system); /* If this fails, you need to compile this file at least once in C++. */ \
assert(outcome_make_result_status_code_failure_system!=NULL); /* If this fails, you need to compile this file at least once in C++. */ \
outcome_make_result_status_code_failure_system((void *) &ret, sizeof(ret), offsetof(struct cxx_result_status_code_##ident, flags), errcode); \
return ret; \
} \
Expand Down
4 changes: 2 additions & 2 deletions test/link/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
set(outcome_LINK_TARGETS)
foreach(type STATIC SHARED)
foreach(visibility default hidden)
set(target outcome-link-test-experimental-c-result-type_${type}-vis_${visibility})
set(target outcome-link-test-c-result-type_${type}-vis_${visibility})
add_library(${target}-lib ${type}
"experimental-c-result/lib.c"
"experimental-c-result/lib.cpp")
Expand All @@ -50,7 +50,7 @@ foreach(type STATIC SHARED)
DISABLE_PRECOMPILE_HEADERS On
)
target_link_libraries(${target} PRIVATE ${target}-lib outcome::hl)
if(target MATCHES ".*-type_SHARED-vis_hidden")
if(target MATCHES ".*-type_SHARED-vis_hidden" OR (WIN32 AND target MATCHES ".*-type_SHARED.*"))
# The shared library won't export the C++ helper machinery if visibility is hidden,
# so without including a copy of the C++ helpers it would correctly fail to link.
add_library(${target}-cxx-helpers OBJECT "experimental-c-result/lib.cpp")
Expand Down

0 comments on commit 72ff7b1

Please sign in to comment.