Prev: Popup tips in tree and lists
Next: THIS_FILE' : redefinition; different storage class while changing setting from /MD to /MDD
From: Joseph M. Newcomer on 28 Apr 2010 09:10 #undef does NOT undefine a symbol such as THIS_FILE; it can only undefine a symbol which has been created by #define! So I have no idea what you are expecting the undef to do. If you had another definition of THIS_FILE somewhere, this second definition is in conflict with it, and the #undef is just silly noise. I have no idea why you would put a #pragma once in a .cpp file! This is appropriate only in header files, and it would NOT be conditioned under an #ifdef _DEBUG! So I have no idea what the intent of the code below might be, except that it is completely wrong in so many ways I'm not surprised it gives errors. Of course, the #pragma once might be because this code was placed in a header file, in which case it is clearly wrong in yet a new way: it is defining a variable (THIS_FILE) which has the WRONG file name (the name of the header file) and which will be included as a static variable in every module of your code. Also, when you quote error messages, it is useful to quote the entire message, which includes the file name. If you want to disguise the file name for proprietary reasons, then replace the name (e.g., productname.h) with XXXXXXXX.h. But since you chose to hide the filename, I'm having to guess at what you did wrong. Fix the nonsense code below, remove the #undef, put it in a .cpp file, and if the problem is that the code is in your .h file, move the code to a .cpp file where it belongs. joe On Wed, 28 Apr 2010 00:20:14 -0700 (PDT), Girish <girishog(a)gmail.com> wrote: >Hi, >I working in finding out the memory leak in the application which was >developed in vc++2005. I am using _CrtMemCheckpoint function to find >out the memory leak these function will be working only when the >application is in debug mode and the project setting should in /MDD >or /MTD . >When ever I change my setting from /MD to /MDD I get a compiler error >Error 251 error C2370: 'THIS_FILE' : redefinition; >different storage class >i.e error is at >#ifdef _DEBUG >#define new DEBUG_NEW >#undef THIS_FILE >#pragma once >static char THIS_FILE[] = __FILE__; >#endif > >When I try to remove this and build I can build the application but it >crashes . >Could you please help me out what is changes I need to make to run >the application successfully. > >Thanks in Advance, >Regards, >Girish Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm |