ForEach macro in TCollection.h

Just run into a problem when trying to compile a code including headers from both ROOT and wxWidgets. It’s turned out that the TCollection.h (in its very end) defines the following macro:

#define ForEach(type,proc)

A problem with this macro is that one of the wxWidget’s classes has a member with exactly the same name, something like:

class wxSomething {
void ForEach();


The C/C++ preprocessor (GCC 3.2.3) will happily replace that method with the above defined macro. The rest is as usualy :slight_smile:

Is there any reason why to have this macro with such generic and non-standard (in terms of ROOT naming conventions) name in a public header? I’ve also noticed that none of other T.h headers in ROOT’s “include/” directory is using that macro (at least in 5.08 and 5.10). If it’s meant to be used in implementation files only then perhaps (may I suggest this?) it may make a sense to move the macro into some private file included by the implementations(?).

Another option would be to rename the macro to something less generic like TForEach, or whatever would seem more appropriate.


Hi Igor,

See the Release Notes of version 5.11/02 at: