samedi 2 avril 2016

C++ enum class quint64 type [duplicate]

This question already has an answer here:

I have following enum class:

#ifndef UEPROTOCOLCOMMANDS_H
#define UEPROTOCOLCOMMANDS_H

enum class UeProcotolCommand
{
    INVALID_COMMAND=0x0000000000000000,

    SERVER_GET_CLIENTS_VERSIONS=0x0000000000000001,
    SERVER_CONNECTION_RESET=0x0000000000000002,

    CLIENT_GET_DATABASE_CREDENTIALS=0x1000000000000001,
    CLIENT_DISCOVER_COMM_SERVER=0x1000000000000002
};   // UeProtocolCommands

#endif // UEPROTOCOLCOMMANDS_H

and it generates following error:

In file included from ../../../../uePOSCommProtocol/net/comm_protocol/uemessageheader.h:6:0,
                 from ../../../../uePOSCommProtocol/net/comm_protocol/uemessagerequest.h:6,
                 from ../../../../uePOSCommProtocol/ueposcommprotocol.h:8,
                 from ../../../uemainwindow.h:16,
                 from ../../../main.cpp:3:
../../../../uePOSCommProtocol/net/comm_protocol/ueprotocolcommands.h:11:37: error: enumerator value 1152921504606846977l is too large for underlying type 'int'
     CLIENT_GET_DATABASE_CREDENTIALS=0x1000000000000001,
                                     ^
../../../../uePOSCommProtocol/net/comm_protocol/ueprotocolcommands.h:12:33: error: enumerator value 1152921504606846978l is too large for underlying type 'int'
     CLIENT_DISCOVER_COMM_SERVER=0x1000000000000002
                                 ^
make: *** [main.o] Error 1
14:23:40: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project uePOSCommClient (kit: Desktop Qt 5.6.0 GCC 64bit)
When executing step "Make"

I need to tell to compiler that enum elements are of type quint64, not the default int. How?

Aucun commentaire:

Enregistrer un commentaire