Re: Index a #define string
On Sat, 17 Apr 2004 14:54:12 -0600 in comp.lang.c++, Julie
<julie@nospam.c om> wrote,[color=blue]
>
>Do you agree that the offsetof() macro is an example of a 'non-evil' macro or
>not?[/color]
It is very nasty in both intent and action. I think it would not exist
in C++ except for the need for backwards C compatibility.
In intent, it breaks encapsulation and encourages dependence on the
low-level layout and implementation of objects. Depend only upon the
classes' public interface. Use "pointer-to-member" when called for.
In action, it relies on non-portable tricks and cannot be defined within
standard C++. Or even C, I think, which is probably why it is in the
library instead of expecting self-abusers to supply their own.
On Sat, 17 Apr 2004 14:54:12 -0600 in comp.lang.c++, Julie
<julie@nospam.c om> wrote,[color=blue]
>
>Do you agree that the offsetof() macro is an example of a 'non-evil' macro or
>not?[/color]
It is very nasty in both intent and action. I think it would not exist
in C++ except for the need for backwards C compatibility.
In intent, it breaks encapsulation and encourages dependence on the
low-level layout and implementation of objects. Depend only upon the
classes' public interface. Use "pointer-to-member" when called for.
In action, it relies on non-portable tricks and cannot be defined within
standard C++. Or even C, I think, which is probably why it is in the
library instead of expecting self-abusers to supply their own.
Comment