#including a file gives errors on rest of parent file
Posted on 1998-05-29
In MSVCPP5.0 I am porting some C code to work on winNT. I have a vcpp class file that works fine. I have a C file that works fine and is composed of a bunch of function prototypes with external linkage. All of my C files I have given .cpp extensions to and am compiling without special extern "C" type modifiers. The problem is that when I #include the (originally) C file into the class file, I get errors on compilation of the class file. I get: "redefinition; different type modifiers" or "overloaded member function not found in 'class'" on the constructor, GetRuntimeClass, _GetBaseMessageMap, GetMessageMap, AFX_MSGMAP, AFX_MSGMAP_ENTRY, AssertValid, and Dump. It's like #including the file makes the compiler read the rest of the parent file differently or something.
I have been able to #include this C file in other C files with no problems. I also have been able to #include one other C file into a C++ class file with no problem.
I also have tried putting the #include inside an extern "C" call and it makes no difference. I seem to recall having this problem once before, on purely vcpp files. Of course I don't recall what fixed it, but it suggests to me that it may have nothing to do with the fact that the offending file was originally C.