I have an ATL COM service and in the .IDL file, I've declared an enum like so:
In Gourmet.idl
typedef enum Food
{
Chocolate = 0,
Doughnut,
HotDog
} Food;
A header file is automatically generated, creating Gourmet_i.h.
In another .CPP file (let's just call it Decadence.cpp) of the same ATL COM project, I #include Gourmet_i.h. I've implemented a class in this .CPP and it's under the namespace 'Chocolate'.
For example in Decadence.cpp:
#include "Gourmet_i.h"
namespace Chocolate {
// Constructor
void Decadence::Decadence() {}
// ... and so on
} // namespace Chocolate
When compiled I get the following error about Gourmet_i.h:
error C2365: 'Chocolate': redefinition; previous definition was 'namespace'
I see this occurs because the enum for the IDL is defined in the global namespace, but is it possible to contain this definition -- so it doesn't pollute the global namespace -- and I wouldn't have this conflict?