Skip to content

Commit

Permalink
Merge pull request #632 from ethereum/helpers_cxx
Browse files Browse the repository at this point in the history
helpers: Improve compatibility with C++
  • Loading branch information
chfast committed Mar 8, 2022
2 parents 9766b77 + e4a7030 commit c4b2453
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ endif()
cable_configure_compiler(NO_STACK_PROTECTION)
if(CABLE_COMPILER_GNULIKE)
# TODO: Resolve issues or remove "result optional storage" and enable -Wcast-align.
add_compile_options(-Wmissing-declarations)
add_compile_options(
-Wmissing-declarations
$<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast>
)
cable_add_cxx_compiler_flag_if_supported(-Wfinal-dtor-non-final-class)
cable_add_cxx_compiler_flag_if_supported(-Wnewline-eof)
cable_add_cxx_compiler_flag_if_supported(-Wsuggest-destructor-override)
Expand Down
2 changes: 1 addition & 1 deletion examples/example_vm/example_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ enum evmc_set_option_result set_option(evmc_vm* instance, const char* name, cons
return EVMC_SET_OPTION_INVALID_VALUE;
if (v > 9 || v < -1) // Not in the valid range.
return EVMC_SET_OPTION_INVALID_VALUE;
vm->verbose = (int)v;
vm->verbose = static_cast<int>(v);
return EVMC_SET_OPTION_SUCCESS;
}

Expand Down
13 changes: 11 additions & 2 deletions include/evmc/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
* These are convenient for languages where invoking function pointers
* is "ugly" or impossible (such as Go).
*
* It also contains helpers (overloaded operators) for using EVMC types effectively in C++.
*
* @defgroup helpers EVMC Helpers
* @{
*/
Expand All @@ -20,6 +18,12 @@
#include <stdlib.h>
#include <string.h>

#ifdef __cplusplus
extern "C" {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
#endif

/**
* Returns true if the VM has a compatible ABI version.
*/
Expand Down Expand Up @@ -293,3 +297,8 @@ static inline const char* evmc_revision_to_string(enum evmc_revision rev)
}

/** @} */

#ifdef __cplusplus
#pragma GCC diagnostic pop
} // extern "C"
#endif

0 comments on commit c4b2453

Please sign in to comment.