gxchain / gxb-core

GXChain Blockchain implementation
https://www.gxchain.org
GNU General Public License v3.0
225 stars 78 forks source link

智能合约编译的一个问题 #170

Closed dremofly closed 5 years ago

dremofly commented 5 years ago

"In file included from .tmp/3dce8bdad2afac30cad0783ae3e28294/vote.cpp:5:\nIn file included from /usr/local/include/graphenelib/dispatcher.hpp:3:\nIn file included from /usr/local/include/graphenelib/action.hpp:3:\nIn file included from /usr/local/include/graphenelib/datastream.hpp:5:\nIn file included from /usr/include/boost/container/flat_set.hpp:27:\nIn file included from /usr/include/boost/container/new_allocator.hpp:24:\n/usr/include/boost/container/throw_exception.hpp:56:21: warning: address of array 'msg' will always evaluate to 'true' [-Wpointer-bool-conversion]\n BOOST_ASSERT(!msg);\n ~^\n/usr/include/boost/assert.hpp:60:36: note: expanded from macro 'BOOST_ASSERT'\n# define BOOST_ASSERT(expr) assert(expr)\n ^~\n/usr/local/include/musl/upstream/include/assert.h:8:28: note: expanded from macro 'assert'\n#define assert(x) ((void)((x) || (assert_fail(#x, FILE, LINE, func),0)))\n ^\nIn file included from .tmp/3dce8bdad2afac30cad0783ae3e28294/vote.cpp:5:\nIn file included from /usr/local/include/graphenelib/dispatcher.hpp:3:\nIn file included from /usr/local/include/graphenelib/action.hpp:3:\nIn file included from /usr/local/include/graphenelib/datastream.hpp:5:\nIn file included from /usr/include/boost/container/flat_set.hpp:27:\nIn file included from /usr/include/boost/container/new_allocator.hpp:24:\n/usr/include/boost/container/throw_exception.hpp:64:25: warning: address of array 'msg' will always evaluate to 'true' [-Wpointer-bool-conversion]\n BOOST_ASSERT_MSG(!msg, str);\n ~^\n/usr/include/boost/assert.hpp:61:46: note: expanded from macro 'BOOST_ASSERT_MSG'\n# define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg))\n ^~\n/usr/local/include/musl/upstream/include/assert.h:8:28: note: expanded from macro 'assert'\n#define assert(x) ((void)((x) || (assert_fail(#x, FILE, LINE, func),0)))\n ^\nIn file included from .tmp/3dce8bdad2afac30cad0783ae3e28294/vote.cpp:5:\nIn file included from /usr/local/include/graphenelib/dispatcher.hpp:3:\nIn file included from /usr/local/include/graphenelib/action.hpp:3:\nIn file included from /usr/local/include/graphenelib/datastream.hpp:5:\nIn file included from /usr/include/boost/container/flat_set.hpp:27:\nIn file included from /usr/include/boost/container/new_allocator.hpp:24:\n/usr/include/boost/container/throw_exception.hpp:72:25: warning: address of array 'msg' will always evaluate to 'true' [-Wpointer-bool-conversion]\n BOOST_ASSERT_MSG(!msg, str);\n ~^\n/usr/include/boost/assert.hpp:61:46: note: expanded from macro 'BOOST_ASSERT_MSG'\n# define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg))\n ^~\n/usr/local/include/musl/upstream/include/assert.h:8:28: note: expanded from macro 'assert'\n#define assert(x) ((void)((x) || (assert_fail(#x, FILE, LINE, func),0)))\n ^\nIn file included from .tmp/3dce8bdad2afac30cad0783ae3e28294/vote.cpp:5:\nIn file included from /usr/local/include/graphenelib/dispatcher.hpp:3:\nIn file included from /usr/local/include/graphenelib/action.hpp:3:\nIn file included from /usr/local/include/graphenelib/datastream.hpp:5:\nIn file included from /usr/include/boost/container/flat_set.hpp:27:\nIn file included from /usr/include/boost/container/new_allocator.hpp:24:\n/usr/include/boost/container/throw_exception.hpp:80:25: warning: address of array 'msg' will always evaluate to 'true' [-Wpointer-bool-conversion]\n BOOST_ASSERT_MSG(!msg, str);\n ~^\n/usr/include/boost/assert.hpp:61:46: note: expanded from macro 'BOOST_ASSERT_MSG'\n# define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg))\n ^~\n/usr/local/include/musl/upstream/include/assert.h:8:28: note: expanded from macro 'assert'\n#define assert(x) ((void)((x) || (assert_fail(#x, FILE, LINE, func),0)))\n ^\nIn file included from .tmp/3dce8bdad2afac30cad0783ae3e28294/vote.cpp:5:\nIn file included from /usr/local/include/graphenelib/dispatcher.hpp:3:\nIn file included from /usr/local/include/graphenelib/action.hpp:3:\nIn file included from /usr/local/include/graphenelib/datastream.hpp:5:\nIn file included from /usr/include/boost/container/flat_set.hpp:27:\nIn file included from /usr/include/boost/container/new_allocator.hpp:24:\n/usr/include/boost/container/throw_exception.hpp:88:25: warning: address of array 'msg' will always evaluate to 'true' [-Wpointer-bool-conversion]\n BOOST_ASSERT_MSG(!msg, str);\n ~^\n/usr/include/boost/assert.hpp:61:46: note: expanded from macro 'BOOST_ASSERT_MSG'\n# define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg))\n ^~\n/usr/local/include/musl/upstream/include/assert.h:8:28: note: expanded from macro 'assert'\n#define assert(x) ((void)((x) || (__assert_fail(#x, FILE, LINE, func),0)))\n ^\n5 warnings generated.\n\n608925ms th_a main.cpp:119 main ] 3010001 name_type_exception: Invalid name\nName not properly normalized (name: vote_action, normalized: vote.action) \n {\"name\":\"vote_action\",\"normalized\":\"vote.action\"}\n th_a name.cpp:15 set\n\n {}\n th_a abi_generator.cpp:183 inspect_type_methods_for_actions\n\n {}\n th_a abi_generator.cpp:299 handle_decl\n\n {\"decl_location\":\"/mnt/node-application/gxx-server/.tmp/3dce8bdad2afac30cad0783ae3e28294/vote.cpp:17:7\"}\n th_a abi_generator.cpp:39 handle_tagdecl_definition\n608925ms th_a main.cpp:119 main ] output: {\"version\":\"gxc::abi/1.0\",\"types\":[],\"structs\":[{\"name\":\"candidate\",\"base\":\"\",\"fields\":[{\"name\":\"id\",\"type\":\"uint64\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"voteCount\",\"type\":\"uint64\"}]},{\"name\":\"voter\",\"base\":\"\",\"fields\":[{\"name\":\"address\",\"type\":\"uint64\"},{\"name\":\"hasVoted\",\"type\":\"bool\"}]},{\"name\":\"vote_action\",\"base\":\"\",\"fields\":[{\"name\":\"_candidateId\",\"type\":\"uint64\"}]}],\"actions\":[],\"tables\":[{\"name\":\"candidate\",\"index_type\":\"i64\",\"key_names\":[\"id\"],\"key_types\":[\"uint64\"],\"type\":\"candidate\"},{\"name\":\"voter\",\"index_type\":\"i64\",\"key_names\":[\"address\"],\"key_types\":[\"uint64\"],\"type\":\"voter\"}],\"error_messages\":[],\"abi_extensions\":[]} \n"

以上是我使用ide时输出的错误信息。信息中没有包含error,有几个一样的warning。不知道为什么编译不出来。这几个warning是什么问题呢。

dremofly commented 5 years ago

似乎是没有生成正确的action

RootkitKiller commented 5 years ago

vote_action 这个是action名字吗,action命名不能有下划线的。

dremofly commented 5 years ago

@RootkitKiller 多谢,原来还有这个问题,难怪改了名字可以。

还有action是不是大括号必须换行。比如说

void hi() {
}

这样就是有问题的。

RootkitKiller commented 5 years ago

@dremofly 客气了,后面的问题不换行,编译的时候报错了吗,有错误信息提供吗,我测试了一下,没有复现出来。

dremofly commented 5 years ago

可能是其他问题,我看错了。都解决了。 @RootkitKiller