LoginSignup
1
1

More than 5 years have passed since last update.

mbed warningを抑止

Posted at

warningが発生

通信のデータフォーマットをstructで定義していて、Idをenum、(通信量を減らすために)enumをuint8_tにすると、

enum ComputerPacketId : uint8_t
{
    COMPUTER_PACKET_CMD_GET_STATUS,
    COMPUTER_PACKET_CMD_SET_SOLENOIDS,
    COMPUTER_PACKET_CMD_END,
    COMPUTER_PACKET_RES_GET_STATUS,
    COMPUTER_PACKET_RES_SET_SOLENOIDS,
};
struct ComputerPacket
{
    uint8_t Sequence;
    ComputerPacketId Id;
    uint8_t Checksum;
    uint8_t DataSize;
    uint8_t Data[10];
};

コンパイルでwarningが発生します。

Warning: Explicit enum base types are a C++11 feature in "Computer.h", Line: 9, Col: 24

20160130B.PNG

warningを抑止するには?

pragma diag_suppressで出来るみたい。

tag?

pragma diag_suppressでtagを指定したいのですが、警告のエラー番号が分からないorz

エクスポートしてオフラインコンパイルすると、エラー番号が分かりました。(^^)/

Computer.h(9): warning: #3641-D: explicit enum base types are a C++11 feature

warning抑止

#pragma push
#pragma diag_suppress 3641  // explicit enum base types are a C++11 feature
enum ComputerPacketId :
uint8_t {
    COMPUTER_PACKET_CMD_GET_STATUS,
    COMPUTER_PACKET_CMD_SET_SOLENOIDS,
    COMPUTER_PACKET_CMD_END,
    COMPUTER_PACKET_RES_GET_STATUS,
    COMPUTER_PACKET_RES_SET_SOLENOIDS,
};
#pragma pop
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1