Added espcppmacros.h
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
set(headers
|
||||
src/espcppmacros.h
|
||||
src/espcrc32builder.h
|
||||
src/esprandom.h
|
||||
src/espstrutils.h
|
||||
|
21
src/espcppmacros.h
Normal file
21
src/espcppmacros.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
namespace espcpputils {
|
||||
|
||||
#define CALL_AND_EXIT_ON_ERROR(METHOD, ...) \
|
||||
if (const auto result = METHOD(__VA_ARGS__); result != ESP_OK) \
|
||||
{ \
|
||||
ESP_LOGE(TAG, "%s() failed with %s", #METHOD, esp_err_to_name(result)); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
#define CALL_AND_EXIT(METHOD, ...) \
|
||||
if (const auto result = METHOD(__VA_ARGS__); result != ESP_OK) \
|
||||
{ \
|
||||
ESP_LOGE(TAG, "%s() failed with %s", #METHOD, esp_err_to_name(result)); \
|
||||
return result; \
|
||||
} \
|
||||
else \
|
||||
return result;
|
||||
|
||||
} // namespace espcpputils
|
Reference in New Issue
Block a user