From 0b9e04db920d3f6a3f8e322e99b9c805799e9683 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Fri, 6 Aug 2021 17:10:51 +0200 Subject: [PATCH] Fixed unique symbol name for result inside macro --- src/espcppmacros.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/espcppmacros.h b/src/espcppmacros.h index 0a1b73b..96c10b7 100644 --- a/src/espcppmacros.h +++ b/src/espcppmacros.h @@ -3,19 +3,19 @@ namespace espcpputils { #define CALL_AND_EXIT_ON_ERROR(METHOD, ...) \ - if (const auto result = METHOD(__VA_ARGS__); result != ESP_OK) \ + if (const auto result##__LINE__ = METHOD(__VA_ARGS__); result##__LINE__ != ESP_OK) \ { \ - ESP_LOGE(TAG, "%s() failed with %s", #METHOD, esp_err_to_name(result)); \ - return result; \ + ESP_LOGE(TAG, "%s() failed with %s", #METHOD, esp_err_to_name(result##__LINE__)); \ + return result##__LINE__; \ } #define CALL_AND_EXIT(METHOD, ...) \ - if (const auto result = METHOD(__VA_ARGS__); result != ESP_OK) \ + if (const auto result##__LINE__ = METHOD(__VA_ARGS__); result##__LINE__ != ESP_OK) \ { \ - ESP_LOGE(TAG, "%s() failed with %s", #METHOD, esp_err_to_name(result)); \ - return result; \ + ESP_LOGE(TAG, "%s() failed with %s", #METHOD, esp_err_to_name(result##__LINE__)); \ + return result##__LINE__; \ } \ else \ - return result; + return result##__LINE__; } // namespace espcpputils