Enum types are great in that they enforce certain values and protect functions from receiving values outside of the desired range. I'm trying to encapsulate my enums in a namespace so that they aren't on the global scope, but I'm hitting some issues that I think are related to circular dependencies. Here's some code excerpts.

color_namespace.h
Qt Code:
  1. #ifndef COLOR_NAMESPACE_H
  2. #define COLOR_NAMESPACE_H
  3.  
  4. #include "colorwriter.h"
  5. //#include lots of other headers
  6.  
  7. namespace CC
  8. {
  9. enum colors_t
  10. {
  11. BLACK = 0,
  12. RED = 1,
  13. BLUE = 2,
  14. GREEN = 4,
  15. WHITE = 8
  16. }
  17. }
  18. #endif
To copy to clipboard, switch view to plain text mode 
colorwriter.h
Qt Code:
  1. #ifdef COLORWRITER_H
  2. #define COLORWRITER_H
  3.  
  4. #include "color_namespace.h"
  5.  
  6. class ColorWriter
  7. {
  8. public:
  9. ColorWriter();
  10. virtual bool writeColor(CC::colors_t c);
  11. }
  12. #endif
To copy to clipboard, switch view to plain text mode 
Now, the problem I'm running into is that I get a compiler error saying that 'CC' has not been declared. My research suggest there's a circular dependency, but how could that be when both headers have include guards? I would like to keep the #include in the namespace because there's a dozen other dependencies and I'd like to enable the user to only have to include one file instead of a dozen.

If the enum was a class, I'd just forward declare it in the .h and #include the namespace in the .cpp, but I can't do that since enums can't be forward declared. Is the value protection provided by an enum simply not possible for functions declared outside that namespace?

Thanks!