Redefining or changing macro value

You can undefine it and define again: #include <iostream> #define AAA 13 int main() { #undef AAA #define AAA 7 std::cout << AAA; } outputs: 7 Please note that statements that start with # are preprocessor directives that are taken care of before the code is even compiled. In this case, this constant AAA will … Read more

How to redefine a Ruby constant without warning?

The following module may do what you want. If not it may provide some pointers to your solution module RemovableConstants def def_if_not_defined(const, value) self.class.const_set(const, value) unless self.class.const_defined?(const) end def redef_without_warning(const, value) self.class.send(:remove_const, const) if self.class.const_defined?(const) self.class.const_set(const, value) end end And as an example of using it class A include RemovableConstants def initialize def_if_not_defined(“Foo”, “ABC”) def_if_not_defined(“Bar”, … Read more

C++ Redefinition Header Files (winsock2.h)

This problem is caused when including <windows.h> before <winsock2.h>. Try arrange your include list that <windows.h> is included after <winsock2.h> or define _WINSOCKAPI_ first: #define _WINSOCKAPI_ // stops windows.h including winsock.h #include <windows.h> // … #include “MyClass.h” // Which includes <winsock2.h> See also this.