ScottishTapWater
ScottishTapWater

Reputation: 4786

Typedef not a member of namespace

So, I'm attempting to fork some open source code and upon compilation I am greeted with these errors:

C2039 'TransactionId': is not a member of 'CryptoNote'

C2061 syntax error: identifier 'TransactionId'

I'm relatively inexperienced with C++ usually confining myself to the realms of C#, however, I can clearly see that TransactionId is a typedef declared in a different file like so:

namespace CryptoNote {

typedef size_t TransactionId;
typedef size_t TransferId;
//more code

And the line throwing the error is:

  void sendTransactionCompleted(CryptoNote::TransactionId _id, bool _error, const QString& _error_text);

To my inexperienced eyes, that looks as though TransactionID is definitly a member of Cryptonote is it not?

Any ideas what's going on?

The repo is here: https://github.com/hughesjs/Incendium_GUI

And the necessary submodule is here: https://github.com/hughesjs/Incendium_Crypt

Upvotes: 0

Views: 1029

Answers (2)

thomas_f
thomas_f

Reputation: 1993

Those typedefs are defined in Incendium_Crypt/include/IWalletLegacy.h.

void sendTransactionCompleted(CryptoNote::TransactionId _id, bool _error, const QString& _error_text);`

is defined in Incendium_GUI/src/gui/SendFrame.h, which includes IWallet.h. However, IWallet.h does not in turn include IWalletLegacy.h. Hence, those typedefs are unknown to SendFrame.h.

Upvotes: 1

digby280
digby280

Reputation: 899

It's difficult to say without seeing all the code but a few things come to mind:

  • Firstly is this the first error you get. Compilation errors with C++ tend to result in a bunch of secondary errors. For example the following results in a similar error to what you see but fails to compile because size_t has not been defined:

    namespace CryptoNote {

    typedef size_t TransactionId; typedef size_t TransferId;

    }

    int main(void) { CryptoNote::TransactionId id; return 0; }

    $ g++ -std=c++11 namespace.cxx -o namespace namespace.cxx:4:9: error: ‘size_t’ does not name a type typedef size_t TransactionId; ^~~~~~ namespace.cxx:5:9: error: ‘size_t’ does not name a type typedef size_t TransferId; ^~~~~~ namespace.cxx: In function ‘int main()’: namespace.cxx:11:17: error: ‘TransactionId’ is not a member of ‘CryptoNote’ CryptoNote::TransactionId id; ^~~~~~~~~~~~~

See http://www.cplusplus.com/reference/cstring/size_t/ for a list of headers that define size_t.

  • Is CryptoNote nested inside another namespace?
  • Is there another CryptoNote defined in the namespace your function is declared in?
  • Are these in the same header file? If not, is the header file where the namespace is defined included in the header file containing the function declaration?

Upvotes: 0

Related Questions