Keil Logo

C51: Error 166 (Array of Functions)

Information in this article applies to:

  • C51 Version 5.50

SYMPTOMS

Does the C51 Compiler support arrays of functions? I get the following error when I try to do that:

Error 166:  'some_functions': array of functions

My program appears as follows:

void function1( void );
void function2( void );
/* ... */
void function39( void );

code void (*some_functions)(void)[] = {
    function1,
    function2,
    /* ... */
    function39
};

What's going on?

CAUSE

C supports arrays of function pointers. It does not support arrays of functions. The declaration you have for the array is close but it is not quite correct.

RESOLUTION

Change your declaration to the following:

code void (code * some_functions []) (void) = { ...

MORE INFORMATION

For more information, refer to Application Note 129.


Last Reviewed: Thursday, February 25, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.