Skip to content

Commit 5bb4cc8

Browse files
committed
accomodate GCC < 10
1 parent 0b10bce commit 5bb4cc8

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/uid/uid.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818

1919
#include "uid.h"
2020

21+
#if __has_attribute(unlikely)
22+
#define UNLIKELY [[unlikely]]
23+
#else
24+
#define UNLIKELY
25+
#endif
26+
2127

2228
extern "C" {
2329
std::string::size_type c_get_uid(char* result, const std::string::size_type buffer_size) {
@@ -27,7 +33,7 @@ std::string::size_type c_get_uid(char* result, const std::string::size_type buff
2733

2834
std::string::size_type str2char(std::string_view s, char* result, const std::string::size_type buffer_size)
2935
{
30-
if(s.length() >= buffer_size) [[unlikely]]
36+
if(s.length() >= buffer_size) UNLIKELY
3137
{
3238
std::cerr << "ERROR: " << s << " " << std::make_error_code(std::errc::result_out_of_range) << "\n";
3339
return 0;

0 commit comments

Comments
 (0)