Skip to content

Commit

Permalink
fix macos build when exceptions disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
odygrd authored Nov 20, 2023
1 parent dcfd8d1 commit ed934b5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
- Reduce backend worker unnecessary allocation. ([#368](https://github.com/odygrd/quill/issues/368))
- Adjusted handling for empty `std::string_view` instances, addressing an issue where logging empty strings triggered an
unintended `memcpy` with zero size and a nullptr, leading to address sanitizer warnings.
- Fix build error on macOS when using '-DQUILL_NO_EXCEPTIONS:BOOL=ON'. ([#357](https://github.com/odygrd/quill/issues/357))

## v3.4.0

Expand Down
2 changes: 2 additions & 0 deletions benchmarks/hot_path_latency/hot_path_bench.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <random>
#include <thread>

#include <x86intrin.h>

// Instead of sleep
inline void wait(std::chrono::nanoseconds min, std::chrono::nanoseconds max)
{
Expand Down
14 changes: 13 additions & 1 deletion quill/include/quill/QuillError.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@
#include "quill/TweakMe.h"

#include "quill/detail/misc/Attributes.h"
#include "quill/detail/misc/Common.h"
#include <exception>
#include <string>

/**
* Require check
*/
#define QUILL_REQUIRE(expression, error) \
do \
{ \
if (QUILL_UNLIKELY(!(expression))) \
{ \
printf("Quill fatal error: %s (%s:%d)\n", error, __FILE__, __LINE__); \
std::abort(); \
} \
} while (0)

#if defined(QUILL_NO_EXCEPTIONS)
#define QUILL_TRY if (true)
#define QUILL_THROW(ex) QUILL_REQUIRE(false, ex.what())
Expand Down
20 changes: 4 additions & 16 deletions quill/include/quill/detail/misc/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

#include "quill/TweakMe.h"

#include "quill/detail/misc/Attributes.h"
#include "quill/Fmt.h"
#include "quill/QuillError.h"
#include "quill/detail/misc/Attributes.h"
#include <functional>
#include <sstream>
#include <string>
Expand Down Expand Up @@ -76,19 +77,6 @@ enum class QueueType
#define QUILL_UNLIKELY(x) (x)
#endif

/**
* Require check
*/
#define QUILL_REQUIRE(expression, error) \
do \
{ \
if (QUILL_UNLIKELY(!(expression))) \
{ \
printf("Quill fatal error: %s (%s:%d)\n", error, __FILE__, __LINE__); \
std::abort(); \
} \
} while (0)

namespace quill
{
namespace detail
Expand Down Expand Up @@ -191,8 +179,8 @@ constexpr bool check_printf_format_string(S format_str)

if (num_specifiers > sizeof...(Args))
{
throw std::runtime_error{
"Invalid printf format: format string does not match number of arguments"};
QUILL_THROW(
QuillError{"Invalid printf format: format string does not match number of arguments"});
}

return true;
Expand Down

0 comments on commit ed934b5

Please sign in to comment.