cannot run the hello contract on the latest master branch build
running eosiocpp -o hello.wast hello.cpp in the /eos/build/contracts/hello folder generates 2 errors. The build is the latest master branch. Nodeos is running and wallets and accounts are created.
eosiocpp -o hello.wast hello.cpp
In file included from hello.cpp:5: In file included from ./hello.hpp:5: In file included from /usr/local/include/eosiolib/eosio.hpp:7: In file included from /usr/local/include/eosiolib/action.hpp:7: In file included from /usr/local/include/eosiolib/datastream.hpp:9: In file included from /home/osboxes/opt/boost_1_66_0/include/boost/container/flat_map.hpp:26: In file included from /home/osboxes/opt/boost_1_66_0/include/boost/container/new_allocator.hpp:24: /home/osboxes/opt/boost_1_66_0/include/boost/container/throw_exception.hpp:56:21: warning: address of array 'msg' will always evaluate to 'true' [-Wpointer-bool-conversion] BOOST_ASSERT(!msg); ~^~~ /home/osboxes/opt/boost_1_66_0/include/boost/assert.hpp:60:36: note: expanded from macro 'BOOST_ASSERT'
define BOOST_ASSERT(expr) assert(expr)
^~~~
/usr/local/include/musl/upstream/include/assert.h:8:28: note: expanded from macro 'assert' #define assert(x) ((void)((x) || (__assert_fail(#x, FILE, LINE, func),0))) ^ In file included from hello.cpp:5: In file included from ./hello.hpp:5: In file included from /usr/local/include/eosiolib/eosio.hpp:7: In file included from /usr/local/include/eosiolib/action.hpp:7: In file included from /usr/local/include/eosiolib/datastream.hpp:9: In file included from /home/osboxes/opt/boost_1_66_0/include/boost/container/flat_map.hpp:26: In file included from /home/osboxes/opt/boost_1_66_0/include/boost/container/new_allocator.hpp:24: /home/osboxes/opt/boost_1_66_0/include/boost/container/throw_exception.hpp:64:25: warning: address of array 'msg' will always evaluate to 'true' [-Wpointer-bool-conversion] BOOST_ASSERT_MSG(!msg, str); ~^~~ /home/osboxes/opt/boost_1_66_0/include/boost/assert.hpp:61:46: note: expanded from macro 'BOOST_ASSERT_MSG'
define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg))
^~~~
/usr/local/include/musl/upstream/include/assert.h:8:28: note: expanded from macro 'assert' #define assert(x) ((void)((x) || (__assert_fail(#x, FILE, LINE, func),0))) ^ In file included from hello.cpp:5: In file included from ./hello.hpp:5: In file included from /usr/local/include/eosiolib/eosio.hpp:7: In file included from /usr/local/include/eosiolib/action.hpp:7: In file included from /usr/local/include/eosiolib/datastream.hpp:9: In file included from /home/osboxes/opt/boost_1_66_0/include/boost/container/flat_map.hpp:26: In file included from /home/osboxes/opt/boost_1_66_0/include/boost/container/new_allocator.hpp:24: /home/osboxes/opt/boost_1_66_0/include/boost/container/throw_exception.hpp:72:25: warning: address of array 'msg' will always evaluate to 'true' [-Wpointer-bool-conversion] BOOST_ASSERT_MSG(!msg, str); ~^~~ /home/osboxes/opt/boost_1_66_0/include/boost/assert.hpp:61:46: note: expanded from macro 'BOOST_ASSERT_MSG'
define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg))
^~~~
/usr/local/include/musl/upstream/include/assert.h:8:28: note: expanded from macro 'assert' #define assert(x) ((void)((x) || (__assert_fail(#x, FILE, LINE, func),0))) ^ In file included from hello.cpp:5: In file included from ./hello.hpp:5: In file included from /usr/local/include/eosiolib/eosio.hpp:7: In file included from /usr/local/include/eosiolib/action.hpp:7: In file included from /usr/local/include/eosiolib/datastream.hpp:9: In file included from /home/osboxes/opt/boost_1_66_0/include/boost/container/flat_map.hpp:26: In file included from /home/osboxes/opt/boost_1_66_0/include/boost/container/new_allocator.hpp:24: /home/osboxes/opt/boost_1_66_0/include/boost/container/throw_exception.hpp:80:25: warning: address of array 'msg' will always evaluate to 'true' [-Wpointer-bool-conversion] BOOST_ASSERT_MSG(!msg, str); ~^~~ /home/osboxes/opt/boost_1_66_0/include/boost/assert.hpp:61:46: note: expanded from macro 'BOOST_ASSERT_MSG'
define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg))
^~~~
/usr/local/include/musl/upstream/include/assert.h:8:28: note: expanded from macro 'assert' #define assert(x) ((void)((x) || (__assert_fail(#x, FILE, LINE, func),0))) ^ In file included from hello.cpp:5: In file included from ./hello.hpp:5: In file included from /usr/local/include/eosiolib/eosio.hpp:7: In file included from /usr/local/include/eosiolib/action.hpp:7: In file included from /usr/local/include/eosiolib/datastream.hpp:9: In file included from /home/osboxes/opt/boost_1_66_0/include/boost/container/flat_map.hpp:26: In file included from /home/osboxes/opt/boost_1_66_0/include/boost/container/new_allocator.hpp:24: /home/osboxes/opt/boost_1_66_0/include/boost/container/throw_exception.hpp:88:25: warning: address of array 'msg' will always evaluate to 'true' [-Wpointer-bool-conversion] BOOST_ASSERT_MSG(!msg, str); ~^~~ /home/osboxes/opt/boost_1_66_0/include/boost/assert.hpp:61:46: note: expanded from macro 'BOOST_ASSERT_MSG'
define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg))
^~~~
/usr/local/include/musl/upstream/include/assert.h:8:28: note: expanded from macro 'assert' #define assert(x) ((void)((x) || (__assert_fail(#x, FILE, LINE, func),0))) ^ hello.cpp:19:38: error: no matching conversion for functional-style cast from 'uint64_t' (aka 'unsigned long long') to 'eosio::name' eosio::print( "Selam Bist: ", eosio::name(code), "->", eosio::name(action), "\n" ); ^~~~~~~~~~~~~~~~ /usr/local/include/eosiolib/types.hpp:75:11: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'uint64_t' (aka 'unsigned long long') to 'const eosio::name' for 1st argument struct name { ^ /usr/local/include/eosiolib/types.hpp:75:11: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'uint64_t' (aka 'unsigned long long') to 'eosio::name' for 1st argument /usr/local/include/eosiolib/types.hpp:75:11: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided hello.cpp:19:63: error: no matching conversion for functional-style cast from 'uint64_t' (aka 'unsigned long long') to 'eosio::name' eosio::print( "Selam Bist: ", eosio::name(code), "->", eosio::name(action), "\n" ); ^~~~~~~~~~~~~~~~~~ /usr/local/include/eosiolib/types.hpp:75:11: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'uint64_t' (aka 'unsigned long long') to 'const eosio::name' for 1st argument struct name { ^ /usr/local/include/eosiolib/types.hpp:75:11: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'uint64_t' (aka 'unsigned long long') to 'eosio::name' for 1st argument /usr/local/include/eosiolib/types.hpp:75:11: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided 5 warnings and 2 errors generated.
+1
I have the same problem any ideas?
resolved by changing the line
void apply( uint64_t receiver, uint64_t code, uint64_t action ) {
to
void apply( uint64_t receiver, eosio::name code, eosio::name action ) {
I am having the same issue as well. It appears that this issue is similar to #2012.
@yanxi-me I was able to compile with void apply( uint64_t receiver, eosio::name code, eosio::name action ) too. I am a bit concerned that the WebAssembly virtual machine looks for a function with the prototype void apply( uint64_t receiver, uint64_t code, uint64_t action ). I could be incorrect however as I am rather new to EOS development.
I attempted to edit types.hpp to add a constructor for struct name. I tried to add a constructor for account_name (typedefed from uint64_t), while keeping the default constructor. Unfortunately, I was unable to get EOS to build without errors after changing this. I have uploaded the types.hpp changes to Gist.
In the mean time, instead of this,
void apply( uint64_t receiver, uint64_t code, uint64_t action ) {
eosio::print( "Hello World: ", eosio::name(code), "->", eosio::name(action), "\n" );
}
I think something like this will work.
void apply( uint64_t receiver, uint64_t code, uint64_t action ) {
eosio::name codeName;
codeName.value = code;
eosio::name actionName;
actionName.value = action;
eosio::print( "Hello World: ", codeName, "->", actionName, "\n" );
}
+1
@brightermatter Do you still encounter this problem on the latest code?
hello contract has been refactored to follow latest eosio framework, it should be fine now