Charles Mills wrote:
Is that true? I know the first part is true: sizeof(foo) or sizeof foo is
evaluated at compile time, not run time. But "not invoked until run time" is
also true for most operators, right? a + b is *generally* evaluated at run
time.
I have a user-defined macro #define elementsof(a) sizeof(a)/sizeof(a[0]). Is
that a function or an operator? It is certainly a "function-type macro."
Charles
There's a lot being thrown around here....
However, there _are_ places in the C language where the compiler must
fold constants at compile time, e.g.:
enum tag { one = (1+0), two = (1+1+0) };
That is obliged to compile and the compiler most compute those
additions to provide the proper values for the "one" and "two" enumeration
constants.
The C standard has more details about this. So most compilers will
easily handle most constant computions (there are several corners
that are interesting to consider... probably only interesting to
compiler writers :-) )
It seems there were plenty of other answers about the vagaries
of parameters and default integer promotions, etc...
- Dave Rivers -
--
[email protected] Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN