#9474 closed Bugs (fixed)
boost/type_traits/has_new_operator.hpp causes compilation errors when macro "new" is defined
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | type_traits |
Version: | Boost 1.55.0 | Severity: | Problem |
Keywords: | Cc: |
Description
It is a recommended practice to #define new DEBUG_NEW in order to detect memory leaks in MFC projects, but it causes compilation errors in boost/type_traits/has_new_operator.hpp due to undesirable macro substitution.
I suggest to hide this macro at the beginning of the file and restore it at the end. Attached patch is suitable only for Visual C++ compiler.
Best regards, Maksim.
Attachments (3)
Change History (8)
by , 9 years ago
Attachment: | has_new_operator.hpp.patch added |
---|
comment:1 by , 9 years ago
follow-up: 3 comment:2 by , 9 years ago
Microsoft, I guess :-)
I'm absolutely agree with about #defining keywords, but this happens.
comment:3 by , 9 years ago
Replying to myasnikovmaksim@…:
Microsoft, I guess :-)
I'm absolutely agree with about #defining keywords, but this happens.
Please don't do this. Repalce instead the global ::new/::delete operators. http://stackoverflow.com/questions/8186018/how-to-properly-replace-global-new-delete-operators
follow-up: 5 comment:4 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed in Git develop, but none the less as Viboes said: "don't do that"!
comment:5 by , 8 years ago
Replying to johnmaddock:
Fixed in Git develop, but none the less as Viboes said: "don't do that"!
Thank you. Needless to say that keyword redefinition is evil, but ancient code can be tricky.
A minor adjustment if you please: there is no reason to keep macro BOOST_TT_AUX_MACRO_NEW_DEFINED defined after pop_macro("new") pragma.
by , 8 years ago
Attachment: | has_new_operator.hpp added |
---|
by , 7 years ago
Attachment: | has_new_operator.hpp.2.patch added |
---|
#undef BOOST_TT_AUX_MACRO_NEW_DEFINED
Recommended by who? You should never #define keywords.