If you see the error along the lines of G__AtToolsLinkDef dictionary payload:1797:2: error: #endif without #if it likely means on of your header files does not end with a newline.
In that case ROOT shoves the headers together in a way where the #ifndef in the header guard is commented out by the previous header file.