function; vs function();

I left the brackets off a function call
no compile error, but no function call either

what does

function;

by itself mean?

Test that the function pointer is non-zero (it will be), and discard the result.

Edit: In practice, you’ll probably find the compiler simply optimises it away

function(); calls the function.
function; is the address of the function.

You can use the latter to assign the function pointer to a variable (or pass it to another function), which you can then reference later on.

It's used by the interrupt system for functions like attachInterrupt() where you pass the function (without brackets) you want to call to the attachInterrupt function, which then stores that function pointer in a variable.

thank you both
that makes sense

had me fooled for a minute or two though:)

Once you realize a "naked function" is the same as the entry point memory address of the function, you can do fun data definitions like:

                 int (*(*fun_one)(char *,double))[9][20];

Using Purdum's Right-Left Rule, you can see this becomes:

fun_one is pointer to function expecting (char *,double) function arguments
returning pointer to array (size 9) of array (size 20) of int.

See either Purdum's C Programming Guide (1983) , or a quick summary at:

http://ieng9.ucsd.edu/~cs30x/rt_lt.rule.html

Pointers to functions can be great.
Instead of a function with a switch-case to many functions by number that you HAVE to go through to access those functions by number, a table of pointers to the same functions can be directly accessed by index (number) faster than using the switch-case by any code that can scope that table. That's a mouthful saying how the pointer table is faster and more flexible once set up. The part I haven't tried yet is using function pointers in PROGMEM.

************* This post started out as an attempt to show how to make

int (*(*fun_one)(char *,double))[9][20];

more clear using typedef.
But between either videocard or java problems (when I'm done here, I'm going godzilla and rebuild on my java install) causing my IDE to act like it's on bad acid I've had to cut it short. My aggro-level is kind of high right now *****************

BTW, properly used, typedef (like enum) is really beautiful for code clarity and brevity.

this works in Arduino IDE 1.03 but note the comments about function address

int func( char *C )
{
  return ( int ) C[ 0 ];
}

int (*foo)(char *) = &func; // this time I use the address-of &

typedef int ( *fun_one )( char * );
fun_one myFun = func; // this time I don't use the address-of &
fun_one fun[9][20];

void setup( void )
{
  Serial.begin( 9600 );
  Serial.println( "test" );
  
  char X[4] = "123";
  Serial.println( foo( X )); // they both seem to work
  Serial.println( myFun( X ));

// the -expletive-deleted- says ambiguous whenever I try an print the function addresses 
  
  while( 1 );
}

void loop( void )
{
}

Useful tutorial links: