添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

error: member reference base type 'uint32_t'(aka 'unsigned int') is not a structure or union [closed]

Ask Question

Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem . This will help others answer the question.

Closed 6 years ago .

Hey Stackoverflow Community, right now i have have the following problem: I want to compile c++ with mac osx.10.11. But every time i want to make the code it gives me an errorcode. I already googled that, but i found nothing.

hashGenesisBlock = uint256("0x01");
if (true && genesis.GetHash() != hashGenesisBlock)
            Logprintf("recalculating params for mainnet.\n");
            Logprintf("old mainnet genesis nonce: %s\n", genesis.nNonce.ToString().c_str());
            Logprintf("old mainnet genesis hash:  %s\n", hashGenesisBlock.ToString().c_str());
            // deliberately empty for loop finds nonce value.
            for(genesis.nNonce == 0; genesis.GetHash() > bnProofOfWorkLimit; genesis.nNonce++){ } 
            Logprintf("new mainnet genesis merkle root: %s\n", genesis.hashMerkleRoot.ToString().c_str());
            Logprintf("new mainnet genesis nonce: %s\n", genesis.nNonce.ToString().c_str());
            Logprintf("new mainnet genesis hash: %s\n", genesis.GetHash().ToString().c_str());

The error message:

Making all in src
  CXX      libgamebit_common_a-chainparams.o
chainparams.cpp:143:13: error: use of undeclared identifier 'Logprintf'
            Logprintf("recalculating params for mainnet.\n");
chainparams.cpp:144:72: error: member reference base type 'uint32_t'
      (aka 'unsigned int') is not a structure or union
  ...Logprintf("old mainnet genesis nonce: %s\n", genesis.nNonce.ToString().c...

Do you have any ideas why im getting this kind of error? Actually im trying to compile bitcoind.

I hope you can help me. Thanks!

Lastly, what is genesis.nNonce? Is it an uint32_t variable? You are programming in C++, not C# or Java or any other language where integers are (or could be) objects. Perhaps you should be reading about the printf format macro constants? – Some programmer dude Jun 5, 2017 at 16:43 The init-decl of your for loop really looks like genesis.nNonce == 0; ? What fiend wrote this "thing" anyway? – WhozCraig Jun 5, 2017 at 16:46

You should concentrate on the first compiler error:

error: use of undeclared identifier 'Logprintf'

That is, you are using this identifier Logprintf, probably a function, but it is not defined. Likely, you are missing a #include that defines it.

The next error:

error: member reference base type 'uint32_t'

if you look at line 144, column 72, it is this one:

Logprintf("old mainnet genesis nonce: %s\n", genesis.nNonce.ToString()
                                                  column 72|

So your nNonce is of type uint32_t and you are trying to call member function ToString() on it. But basic types in C++ do not have member functions, only structures (ie, classes) and unions have.

I suspect that you are trying to compile some C++/CLI code with a pure C++ compiler. I'm afraid some translation will be needed.

This last error, you can fix, once you have the proper definition of Logprintf, by writing:

Logprintf("old mainnet genesis nonce: %u\n", (unsigned)genesis.nNonce);
                It's not C++/CLI, it's based on the Bitcoin source code which uses ToString() and GetHash() (versus GetHashCode(), which C# and C++/CLI have).
– cdhowie
                Jun 5, 2017 at 16:51
                @cdhowie: Ah, that makes sense. But in this code nNonce is of type uint32_t, not uint256. Anyway, removing the .ToString().c_str() and replacing the %s with %d should just work.
– rodrigo
                Jun 5, 2017 at 16:53
                Right. My suspicion is that it's just bitrot. There was a time when the Bitcoin code used a lot of wrapper types to provide formatting members around basic numeric types. (The original author didn't really know idiomatic C++ very well and didn't know that was an anti-pattern.) A lot of that stuff has been patched out, but I suspect that this is old code that builds using Bitcoin's own headers, and hasn't been updated in a long time.
– cdhowie
                Jun 5, 2017 at 16:56
                Thanks for your answers! Just found out that LogPrint is declared like this: static inline int LogPrint(const char* category, const char* format)
– Daniel Beller
                Jun 5, 2017 at 17:04
                But im getting still errors. Right now my logprint looks like this: "LogPrint("old mainnet genesis nonce:", genesis.nNonce);"
– Daniel Beller
                Jun 5, 2017 at 17:06