- Inline functions, ODR, logging - 3 Updates
Andreas <nospam@invalid.invalid>: Nov 16 11:32PM +0100 >>> The (void) above is a C-ism. >> so what? It's both legal and expressive. > It doesn't express anything in C++. Hmm, it at least makes explicit that the function does have no arguments. Such redundancies are often useful, IMHO. For example the braces in if (test()) { do_something(); } do not express anything but I really prefer them being used. After all code is not just read by compilers but (more importantly) by human beings who sometimes may appreciate redundancies/explicitness. -- What do you mean? An African or a European swallow? |
Paavo Helde <myfirstname@osa.pri.ee>: Nov 17 12:39AM +0200 On 17.11.2016 0:15, Andreas wrote: > } > As your LOGGER macro uses __FILE__, it will violate ODR when used in > Bogus::p in the same way that the use of FOOBAR will violate it. No it doesn't violate ODR, __FILE__ will be the same in all compilation units (namely, "f.hh"). |
Andreas <nospam@invalid.invalid>: Nov 16 11:52PM +0100 > Changing the meaning of an include file depending on the definition of a > macro is evil, and that is the root of the problem here. While I agree to your considerations about macros, this statement seems to be a little too broad for me to buy it. I think it is quite common to change the meaning of include files depending on a macro definition. Some examples are: * macros which expand to declspec(dllimport) or declspec(dllexport) (or corresponding __attribute__ annotations) depending on from where they are included * adding or removing declarations (like typedefs) to/from include files depending on macro deinitions For instance glibc headers are full of those. -- What do you mean? An African or a European swallow? |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment