1

I have C headers which forward declare enums. Apparently, this is not possible in C++, so all of the pre-processor wraps of the form

extern "C" {
  #include <header.h>
}

are not going to help. Is there any way to include these headers in a C++ translation unit without requiring me to edit the C headers? Fortunately, modifying the C headers to avoid the forward declaration in this case is relatively painless, but this strikes me as being a pretty significant problem. In general, I had thought it was always possible to link against a C library from C++, but the inability to include the header seems to make that impractical in some cases.

Somewhat related questions: 71416 681243

Community
  • 1
  • 1
William Pursell
  • 204,365
  • 48
  • 270
  • 300

1 Answers1

0

Forward declared enums are available in C++0x. If your compiler doens't support it yet, then wrapping enums in namespaces will avoid violation of ODR.

P.S. a good explanation: http://www.devx.com/cplus/Article/42478/1954?pf=true

Gene Bushuyev
  • 5,512
  • 20
  • 19