c++ - global scope enum and namespace conflict -


i have atl com service , in .idl file, i've declared enum so:

in gourmet.idl

typedef enum food {     chocolate = 0,     doughnut,     hotdog } food; 

a header file automatically generated, creating gourmet_i.h.

in .cpp file (let's call decadence.cpp) of same atl com project, #include gourmet_i.h. i've implemented class in .cpp , it's under namespace 'chocolate'.

for example in decadence.cpp:

#include "gourmet_i.h"  namespace chocolate {  // constructor void decadence::decadence() {}  // ... , on  } // namespace chocolate 

when compiled following error gourmet_i.h:

error c2365: 'chocolate': redefinition; previous definition 'namespace' 

i see occurs because enum idl defined in global namespace, possible contain definition -- doesn't pollute global namespace -- , wouldn't have conflict?

short of renaming namespace or enum member solution wrap contents of generated header file in namespace. not without pitfalls , depending on how contents of midl file may cause few headaches. cleanest way can see create proxy header file declares namespace includes midl generated header file.

gourmet.h

namespace midlstuff {     #include "gourmet_i.h" } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -