On Mon, 5 Nov 2001 23:34:59 -0500, dman <[EMAIL PROTECTED]> wrote: > On Mon, Nov 05, 2001 at 03:42:55PM +0100, martin f krafft wrote: > | * Erik Steffl <[EMAIL PROTECTED]> [2001.11.04 17:20:37-0800]: > | > not sure if it's clear but there's a difference when sizeof's argument > | > is array or pointer: > | > | yes. which is exactly why i pointed this out. sizeof is a compile-time > | function. that's the main point. > > \begin{nitpick} > IIRC sizeof() is a macro. Anyways, C doesn't have inline > functions so all funcitons are invoked at runtime. > \end{nitpick}
<nitpick>C does too have inline functions (C99, that is)</nitpick> #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <math.h> #ifdef __USE_ISOC99 inline void func(double, double, double *, double *); #else void func (double, double, double *, double *); #endif void func (double a, double b, double *e, double *inv_f) { assert (a >= b && b > 0); *e = sqrt(a*a - b*b) / a; *inv_f = a / (a - b); } ... int main (int argc, char **argv) { // stuff func (a, b, &e, &inv_f); // more stuff } $ gcc -pg -O2 -Wall -D_ISOC99_SOURCE -o foo foo.c -lm Will produce a binary with an inlined function (need optimization flag). -- Eric G. Miller <egm2@jps.net>