From e7f296c2d7ee252681913adcfc8d45ebe3fab550 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 11 Nov 2020 22:01:57 +0000 Subject: [PATCH 1/3] Use #ifdef instead of #if where appropriate --- include/evmc/evmc.h | 6 +++--- include/evmc/instructions.h | 4 ++-- include/evmc/loader.h | 4 ++-- include/evmc/utils.h | 2 +- lib/loader/loader.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/evmc/evmc.h b/include/evmc/evmc.h index e86a11194..88be51b61 100644 --- a/include/evmc/evmc.h +++ b/include/evmc/evmc.h @@ -28,7 +28,7 @@ #include /* Definition of size_t. */ #include /* Definition of int64_t, uint64_t. */ -#if __cplusplus +#ifdef __cplusplus extern "C" { #endif @@ -917,7 +917,7 @@ struct evmc_vm /* END Python CFFI declarations */ -#if EVMC_DOCUMENTATION +#ifdef EVMC_DOCUMENTATION /** * Example of a function creating an instance of an example EVM implementation. * @@ -936,7 +936,7 @@ struct evmc_vm struct evmc_vm* evmc_create_example_vm(void); #endif -#if __cplusplus +#ifdef __cplusplus } #endif diff --git a/include/evmc/instructions.h b/include/evmc/instructions.h index 241e8f5c5..1bfcd9ef4 100644 --- a/include/evmc/instructions.h +++ b/include/evmc/instructions.h @@ -16,7 +16,7 @@ #include #include -#if __cplusplus +#ifdef __cplusplus extern "C" { #endif @@ -219,7 +219,7 @@ EVMC_EXPORT const struct evmc_instruction_metrics* evmc_get_instruction_metrics_ */ EVMC_EXPORT const char* const* evmc_get_instruction_names_table(enum evmc_revision revision); -#if __cplusplus +#ifdef __cplusplus } #endif diff --git a/include/evmc/loader.h b/include/evmc/loader.h index 523139e31..653b3b7de 100644 --- a/include/evmc/loader.h +++ b/include/evmc/loader.h @@ -14,7 +14,7 @@ */ #pragma once -#if __cplusplus +#ifdef __cplusplus extern "C" { #endif @@ -163,7 +163,7 @@ struct evmc_vm* evmc_load_and_configure(const char* config, */ const char* evmc_last_error_msg(); -#if __cplusplus +#ifdef __cplusplus } #endif diff --git a/include/evmc/utils.h b/include/evmc/utils.h index 03715c0b0..34cf26b2b 100644 --- a/include/evmc/utils.h +++ b/include/evmc/utils.h @@ -27,7 +27,7 @@ * @def EVMC_NOEXCEPT * Safe way of marking a function with `noexcept` C++ specifier. */ -#if __cplusplus +#ifdef __cplusplus #define EVMC_NOEXCEPT noexcept #else #define EVMC_NOEXCEPT diff --git a/lib/loader/loader.c b/lib/loader/loader.c index 0cd4834e7..5b8b3c3a2 100644 --- a/lib/loader/loader.c +++ b/lib/loader/loader.c @@ -15,7 +15,7 @@ #if defined(EVMC_LOADER_MOCK) #include "../../test/unittests/loader_mock.h" -#elif _WIN32 +#elif defined(_WIN32) #include #define DLL_HANDLE HMODULE #define DLL_OPEN(filename) LoadLibrary(filename) @@ -136,7 +136,7 @@ evmc_create_fn evmc_load(const char* filename, enum evmc_loader_error_code* erro // Find filename in the path. const char* sep_pos = strrchr(filename, '/'); -#if _WIN32 +#ifdef _WIN32 // On Windows check also Windows classic path separator. const char* sep_pos_windows = strrchr(filename, '\\'); sep_pos = sep_pos_windows > sep_pos ? sep_pos_windows : sep_pos; From 9ac30407ec4eb1689a2f7d45fdc45887dbcf2a68 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 11 Nov 2020 22:02:36 +0000 Subject: [PATCH 2/3] Use proper prototype for evmc_last_error_msg(void) --- include/evmc/loader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/evmc/loader.h b/include/evmc/loader.h index 653b3b7de..868751652 100644 --- a/include/evmc/loader.h +++ b/include/evmc/loader.h @@ -161,7 +161,7 @@ struct evmc_vm* evmc_load_and_configure(const char* config, * @return Error message or NULL if no additional information is available. * The returned pointer MUST NOT be freed by the caller. */ -const char* evmc_last_error_msg(); +const char* evmc_last_error_msg(void); #ifdef __cplusplus } From 5794a34c1c70d9de980d5d79074bd9e43636f593 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 11 Nov 2020 22:07:01 +0000 Subject: [PATCH 3/3] Add virtual destructor to example vm --- examples/example_host.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/example_host.cpp b/examples/example_host.cpp index 64e914cab..82a44db7b 100644 --- a/examples/example_host.cpp +++ b/examples/example_host.cpp @@ -20,6 +20,8 @@ namespace evmc { struct account { + virtual ~account() = default; + evmc::uint256be balance = {}; std::vector code; std::map storage;