mardi 9 mai 2023

How to use enum identifier when a macro of same name exists?

I am trying to work with an enum where one of the enum values is defined as a macro.

enum class Method
{
  GET, 
  POST, 
  PUT, 
  HEAD 
  // I want to add DELETE
};

This enum is being used ahead where values are being converted to string.

But when I add DELETE it says this is defined as a macro in one of the .h files I am using in the class - winnt.h.

In winnt.h, DELETE is defined as:

#define DELETE                           (0x00010000L)

The compiler gives an error saying 'expected an identifier'.

I don't want to change my code WHERE the enum is being used and converted to a string.

How can I add this DELETE value to my enum?

Aucun commentaire:

Enregistrer un commentaire