locked
predefined types RRS feed

  • Question

  • Hey everyone,

    Is there a way to tell the compilier to stop using its predefined structures and classes? Right now I am getting a bit of errors simular to this:

    Code Snippet

    1>.\Lib\cstd.cpp(201) : error C2011: '_PMD' : 'struct' type redefinition
    1>        predefined C++ types (compiler internal)(41) : see declaration of '_PMD'


    I cannot seem to find a way to do this and wont be able to use exception handling nor virtual functions within MSVC++ without this working.

    If there is no way, then my question becomes why isn't this true for all built in structures and classes? ie; useually I would just get a linker error (undefined symbol) if a built-in symbol is missing and needs to be defined. In this case that isnt true.

    Thanks for any help Smile
    Saturday, October 25, 2008 10:39 PM

Answers

  •  mt2002 wrote:
    However, because I am using my own runtime and not the standard runtime


    You are completely on your own with this.  We cannot possibly support somebody that chooses not to link the standard CRT supplied by Microsoft.  This might have been feasible 10 years ago but it is no longer.  The C/C++ compiler makes lots of assumptions about what is available at runtime.

    If you are doing this because of some kind of embedded system environment, you'll need to look into cross-compiler support from vendors that support that platform.

    Wednesday, October 29, 2008 10:09 PM
    Moderator

All replies

  • If we cant get the above working, does anyone have any suggestions for this?

    Code Snippet

    error LNK2001: unresolved external symbol "const type_info::`vftable'" (??_7type_info@@6B@)


    Any time that I attempt to use the throw keyword, I get the above error. I have read the microsoft artical on it, however it does not apply to me. Is there any way that I can fix this in code or compilier/linker option?

    Thanks again for any help!
    Sunday, October 26, 2008 1:46 AM
  • Please, only one question per thread.  Identifiers with a leading underscore are reserved to Microsoft, you can't declare your own without risking errors like these.  Or errors in a future version.
    Sunday, October 26, 2008 6:08 PM
    Moderator
  • I decided to bring up the vtable error because that was the source of the original problem that I was having. I am uncertain if I can fix the error however because the type_info structure is a predefined class.

    This code is for my runtime code so I am seeing if there is a way that I can get try/catch/ and throw working. Whenever I use the throw keyword I get the vftable error (Shown in my previous post).

    I managed to solve the original problem do to a silly error on my part (working with an uninitialized pointer..hehe) so Im not too worried about it if we are unable to get it working or if it is not possible.

    Thanks for your reply. Also, I apologize for posting two questions in this thread--they both were related to the same issue of getting the throw keyword working.

    If you know if it is possible or have suggestions to get it working that would be great. If not, no worries Smile
    Monday, October 27, 2008 1:09 AM
  • Hi mt2002,

    Based on my understanding for the first question, since the error is caused by the “_PMD” struct redefinition, there are probably the following reasons probably would cause this error.


    1.  Check if the “_PMD” structure is defined or declared in a header file, to include this file more than one time in a source file perhaps lead to redefinition error, try to wrap the header file with the following code snippet to overcome this issue.

    Code Snippet

    #ifndef HEADER_FILE_NAME

    #define HEADER_FILE_NAME


    // the header file body content goes here


    #endif


    2. If there is name “_PMD” is used in other libraries or source code in this project as well as “.\Lib\cstd.cpp(201)”, rename the “_PMD” in “cstd.cpp” with other name.


    If you still cannot figure the issue out, please post the code snippet or you can just compress your project and upload it to some network drives, such as http://skydrive.live.com/


    Let us can repro your error, so that we download the project and fix this error.

    Regards

    Xun

    Wednesday, October 29, 2008 2:54 AM
  • Thanks for your response!

    since the error is caused by the “_PMD” struct redefinition, there are probably the following reasons probably would cause this error.

    I am actually getting it on alot of the structures defined within my C STD runtime library (Which is being compilied out now do to the errors). We can focus on the _PMD error for now though as I suspect that will solve the other errors.

    1.  Check if the “_PMD” structure is defined or declared in a header file, to include this file more than one time in a source file perhaps lead to redefinition error, try to wrap the header file with the following code snippet to overcome this issue.

    Its defined once within a source file. The source file is never included into any other file but rather compilied in with the rest of the project.
    2. If there is name “_PMD” is used in other libraries or source code in this project as well as “.\Lib\cstd.cpp(201)”, rename the “_PMD” in “cstd.cpp” with other name.

    Cant do that. The purpose of the additional code was to fix the compilier to properly handle the throw keyword. However, because I am using my own runtime and not the standard runtime, MSVC++ is giving me errors about missing members within its own built in structures:

    Code Snippet

    error LNK2001: unresolved external symbol "const type_info::`vftable'" (??_7type_info@@6B@)



    Thus I am looking for a way to either allow the throw keyword to work without the above error, or force the compilier to use my own defined structures rather then its built in ones.

    (I cannot define type_info without the same redifinition error that I get with _PMD, although I have never defined type_info before. This is the same problem that I am having with _PMD... I get the above error anytime I attempt to throw anything via the C++ throw keyword. So without this working I cant use exceptions...)

    Thus renaming the structure will not work.

    If you still cannot figure the issue out, please post the code snippet or you can just compress your project and upload it to some network drives, such as http://skydrive.live.com/


    I cant post the entire project as it is not a standard Win32 exectable. ie; there is no way to run it from Windows.

    I can post a code snipplet or upload my cstd.cpp file if you like.


    Wednesday, October 29, 2008 9:37 PM
  •  mt2002 wrote:
    However, because I am using my own runtime and not the standard runtime


    You are completely on your own with this.  We cannot possibly support somebody that chooses not to link the standard CRT supplied by Microsoft.  This might have been feasible 10 years ago but it is no longer.  The C/C++ compiler makes lots of assumptions about what is available at runtime.

    If you are doing this because of some kind of embedded system environment, you'll need to look into cross-compiler support from vendors that support that platform.

    Wednesday, October 29, 2008 10:09 PM
    Moderator
  • You are completely on your own with this.  We cannot possibly support somebody that chooses not to link the standard CRT supplied by Microsoft.  This might have been feasible 10 years ago but it is no longer. 

    The above could have been worded in a nicer way. I do agree with you 100% though with the above, but it does not apply to this project.

    I did mention I am using my own runtime in my 3rd post Wink I supposed I didnt make that clear though, sorry.

    Its for a self hosted embedded platform, so I dont have much choice -- Sorry. Most of the runtime works fine already which is why I am not too worried about it. I am still curious how the Microsoft runtime does it though. Because I am using Microsoft Visual C++ I figured that someone here might know.

    Thanks though Big Smile
    Thursday, October 30, 2008 2:09 AM