Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: C++ question (OT)

Author: Vincent Vega

Date: 19:19:59 01/18/01

Go up one level in this thread


On January 18, 2001 at 18:22:21, David Rasmussen wrote:

>Is there any reason _not_ to use inline functions instead of small utility
>macros?
>
>For instance, would there be any difference between
>
>#define File(sq) (sq & 7)
>
>and
>
>inline int File(int sq)
>{
>  return (sq & 7);
>}
>
>besides the type checking and other nice things that might be gained?
>
>Would there be any downside to the inline function?

There are some small differences.  Functions can sometimes be better because if
you use a macro, every time you use an argument in a macro, it is evaluated.  So
you have to be careful with more complex macros and complex arguments (like
f(++x)).  Another difference is that in a macro you can't get to class member
data.  Yet another small difference is that inline functions don’t always have
to be actually expanded inline by the compiler.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.