3

I am pretty desperate at this point to search for hints on this issue, though I am pretty sure it's because I'm new to C++ include system. I am getting an error while trying to run a wasm executable that is a result of my project's compilation in Clion. I am trying to run simple contract and #include <eosiolib/eosio.hpp>

[100%] Linking LLVM bitcode executable products.bc
[100%] Generating textual assembly products.s
[100%] Generating WAST products.wast
[100%] Generating products.wast.hpp
[100%] Generating WASM products.wasm
[100%] Built target products

I am able to build the project fine, but then receive errors below

../eosiolib/types.h:26:18: error: redefinition of 'time' as different kind of symbol
typedef uint32_t time;
                 ^
/usr/include/time.h:117:8: note: previous definition is here
time_t time(time_t *);
       ^

followed with

../eosiolib/print.h:86:26: error: unknown type name 'int128_t'
   void printi128( const int128_t* value );
                         ^
../eosiolib/print.h:99:27: error: unknown type name 'uint128_t'
   void printui128( const uint128_t* value );

I have tried solutions from here and some forum posts, but nothing helped yet.

UPDATE Project Structure Main CMakeLists.txt My smart contract subfolder CMakeLists.txt I wonder if someone might have an empty compilable project for CLion? Those I found were outdated and won't compile

The error below shows that time in lib is conflicting with time in /usr/include. I am not including it anywhere I believe? How do I check where is it included from?

/Users/lonkly/CLionProjects/clarity_demo2/eos_contracts/hello/hello.cpp:1:

In file included from /Users/lonkly/CLionProjects/clarity_demo2/eos_contracts/hello/../eosiolib/eosio.hpp:6:
In file included from /Users/lonkly/CLionProjects/clarity_demo2/eos_contracts/hello/../eosiolib/types.hpp:6:
/Users/lonkly/CLionProjects/clarity_demo2/eos_contracts/hello/../eosiolib/types.h:25:18: error: redefinition of 'time' as different kind of symbol

Full copypaste of error log here

  • did you figure out this error? can you share your findings? thank you. – Ovi Aug 2 '18 at 0:18
  • well turned out michael_eos42 was actually right, because this error means you are including the same libraries twice somewhere in code or includes or cmakelists – Lonkly Aug 8 '18 at 10:59
3

The problem is that the code you have written is somehow accessing both the standard C++ definition of time (from /usr/include/time.h) and also the EOS.IO definition of time (from ../eosiolib/types.h).

All I can think is that something in the building of the system has conflicting include paths. Unless you are doing someting like:

#include "time.h"

(which you shouldn't be doing)

Without seeing more code, I don't think I can help any more than that.

|improve this answer|||||
  • 1
    turned out you sir were right. CMakeLists and how you add dependencies is a bit out of scope, but is a right place to look into. – Lonkly Aug 8 '18 at 14:17
  • Glad that I could help, by all means edit my answer to make it more specific and accept it if you like – Phillip Hamnett - EOS42 Aug 8 '18 at 14:33
  • 1
    As an addition for anyone who comes here looking for how to get the time from within eos.io, the answer is to user current_time() – Phillip Hamnett - EOS42 Aug 8 '18 at 14:34
1

Try using uint64_t to store your time and current_time() defined in the wasm_interface.hpp to get the current time.

It's worth noting that some c++ functionality may not be available within the eos context, as the blockchain needs to be "replayable". Therefore, some functionality has either been removed or wrapped to ensure that the blockchain remains atomic.

|improve this answer|||||
  • agree, you can not call the system time. – Jimmy Guo Jul 16 '18 at 9:52
  • I am not including it anywhere in my headers – Lonkly Jul 16 '18 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.