Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualCornstalks

Posted 26 September 2012 - 11:33 AM

Ugh... rapidshare...

Ok I found a way to pass the arguments in the delete operator by a global variables like this:

#define DELETE_OLD delete
#define delete 0; while(bIsDeleteParamsPassing); bIsDeleteParamsPassing=true; chFile=(char*)__FILE__; inLineNo=__LINE__; DELETE_OLD

Please don't.
#define DBG_DELETE delete(__FILE__, __LINE__)
#define delete DBG_DELETE
should work (edit: turns out C++ doesn't support such syntax). If it doesn't, people can help you fix it... you didn't post the actual error when you said "This doesn't work." If you do, we can help you figure out what's up with it.

If you want some reasoning why I say the above code is bad, all you have to do is look at bIsDeleteParamsPassing... is that supposed to be some kind of mutex? You realize it doesn't work to protect your code in a multithreaded environment, right? I'm also unsure of why the 0; is there...

And just a few more critiques on your code:
  • Be consistent with the std namespace. Sometimes you just say size_t instead of std::size_t. You should always use the fully qualified std:: prefix in header files (and also in source files, unless you do using namespace std).
  • If you're going to use global variables (which you shouldn't be), put them in a namespace
  • Be consistent in your type names. Sometimes you use unsigned int, sometimes UINT
  • Consider using proper types for booleans (i.e. use false instead of 0 when assigning to a bool)

#2Cornstalks

Posted 21 September 2012 - 01:35 PM

Ugh... rapidshare...

Ok I found a way to pass the arguments in the delete operator by a global variables like this:

#define DELETE_OLD delete
#define delete 0; while(bIsDeleteParamsPassing); bIsDeleteParamsPassing=true; chFile=(char*)__FILE__; inLineNo=__LINE__; DELETE_OLD

Please don't.
#define DBG_DELETE delete(__FILE__, __LINE__)
#define delete DBG_DELETE
should work. If it doesn't, people can help you fix it... you didn't post the actual error when you said "This doesn't work." If you do, we can help you figure out what's up with it.

If you want some reasoning why I say the above code is bad, all you have to do is look at bIsDeleteParamsPassing... is that supposed to be some kind of mutex? You realize it doesn't work to protect your code in a multithreaded environment, right? I'm also unsure of why the 0; is there...

And just a few more critiques on your code:
  • Be consistent with the std namespace. Sometimes you just say size_t instead of std::size_t. You should always use the fully qualified std:: prefix in header files (and also in source files, unless you do using namespace std).
  • If you're going to use global variables (which you shouldn't be), put them in a namespace
  • Be consistent in your type names. Sometimes you use unsigned int, sometimes UINT
  • Consider using proper types for booleans (i.e. use false instead of 0 when assigning to a bool)

#1Cornstalks

Posted 21 September 2012 - 01:31 PM

Ugh... rapidshare...

Ok I found a way to pass the arguments in the delete operator by a global variables like this:

#define DELETE_OLD delete
#define delete 0; while(bIsDeleteParamsPassing); bIsDeleteParamsPassing=true; chFile=(char*)__FILE__; inLineNo=__LINE__; DELETE_OLD

Please don't.
#define DBG_DELETE delete(__FILE__, __LINE__)
#define delete DBG_DELETE
should work. If it doesn't, people can help you fix it... you didn't post the actual error when you said "This doesn't work." If you do, we can help you figure out what's up with it.

If you want some reasoning why I say the above code is bad, all you have to do is look at bIsDeleteParamsPassing... is that supposed to be some kind of mutex? You realize it doesn't work to protect your code in a multithreaded environment, right?

And just a few more critiques on your code:
  • Be consistent with the std namespace. Sometimes you just say size_t instead of std::size_t
  • If you're going to use global variables (which you shouldn't be), put them in a namespace
  • Be consistent in your type names. Sometimes you use unsigned int, sometimes UINT
  • Consider using proper types for booleans (i.e. use false instead of 0 when assigning to a bool)

PARTNERS