I'm creating a dll + supporting header for a C library; which then has a C++ implementation.
The header file exposes an enum, returned by some of the functions.
Is this example guaranteed to produce ABI compatible libraries?
#ifdef __cplusplus
#define ENUM_DECL enum class
#else
#define ENUM_DECL enum
#endif
extern "C" {
typedef ENUM_DECL Example { value1} Example;
}
Or will the class part of the declaration result in name mangling?
My understanding is that enum and enum class should be syntactical wrappers around an int (or the specified type if given) meaning that it shouldn't matter which one is used except to the usage of it.
Having built it, and used dependency walker to view the dll, I found that it uses the header to establish the return value; which isn't going to help demonstrate if it's compatible.
Naturally, I've asked a couple of AI's to help answer, and one reported that it was ABI compatible, and one said it wasn't.
enumandenum classare implemented the same, they are not the same thing. Why not use a plain Cenumonly (at least for the interface) ?enum class. I hesitate to VTC as a dupe, however, because I'm not really satisfied with the answers to that.