Thining in C++ book and a guidline

Dear all,
I read in end of Volume 1 of thinking C++ book (guidelines section):
"Avoid the preprocessor. Always use const for value
substitution and inlines for macros."
I like preprocessor and use them, if my macro is big, an inline finction can't answer me.
do you have any idea?
Maybe the author meant to say "Try to avoid the preprocessor. Favour const for value substitution and inline functions over macros."

Here's a helpful quote (I didn't think it up. I've seen it used somewhere on these forums):

Unattributed wrote:
Always and never rules are never correct and should always be avoided.
Last edited on
If the macro is too big, you probably* shouldn't be using a macro at all.


* There are a few cases involving repetitive code and early returns where macros are the way to go, but they're a minuscule minority.
an inline finction can't answer me.

You might want to explain that in more detail.
Inline functions can't answer you? Huh? My understanding of inline functions is that they are functions but instead of referring back to the prototype/definition the inline makes the compiler put the function code copied into the function calls location. So I am uncertain what you mean by it can't answer you.
Actually, the inline just tells your compiler that you want the function to be inlined, the compiler isn't required to do it. Likewise, a compiler may choose to inline a function that wasn't explicitly declared as such.
Last edited on
Topic archived. No new replies allowed.