I have code that uses a preprocessor structure to generate some utility classes. Apparently, some macros cause the same friend declaration to be included twice in the class, something like this:
class Friendly { // ::: friend class Bestie; friend class Bestie; // ::: };
When building with gcc (4.8.1), it generates a warning like
Bestie already a friend of Friend [enabled by default]
I do not see use in this warning. I am curious why it was included in gcc in the first place. However, since this is unlikely to meet the SO community, I will pose my question as follows: What problems can arise when the friend declaration repeats, or about probable programmer errors in this case?
The only problem I can think of is, "Perhaps you intended to write something else here instead of repeating the same, so I will warn you about it." However, in this case, the alleged friendship will be absent, which will lead to an "access control violation" error in the code in which the friendship is made, so I almost do not use the warning itself.
Are there any potential issues that I am missing?
source share