c++crtems

`Too many initializers` for for array setup in RTEMS driver definition


Background

I am using RTEMS and trying to set up a native NFS client. Although i have included this correctly there are not enough dynamic driver entries available for the Driver. You can seek more information here.

Implementation

In order to set up the extra dynamic drivers one needs to add NULL elements to a large table of free drivers. See the following:

#define NULL_DRIVER_TABLE_ENTRY \
 { NULL, NULL, NULL, NULL, NULL, NULL}


#ifdef CONFIGURE_INIT
  rtems_driver_address_table Device_drivers[] = {
    #ifdef CONFIGURE_BSP_PREREQUISITE_DRIVERS
      CONFIGURE_BSP_PREREQUISITE_DRIVERS,
    #endif
    #ifdef CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS
      CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS,
    #endif

   ...

    #ifdef CONFIGURE_APPLICATION_EXTRA_DRIVERS
      CONFIGURE_APPLICATION_EXTRA_DRIVERS,
    #endif
    #ifdef CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER
      NULL_DRIVER_TABLE_ENTRY
    #elif !defined(CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER) && \
        !defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER) && \
        !defined(CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER) && \
        !defined(CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER) && \
        !defined(CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER) && \
        !defined(CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER) && \
        !defined(CONFIGURE_APPLICATION_EXTRA_DRIVERS)
      NULL_DRIVER_TABLE_ENTRY
    #endif
  };
#endif

Essentially what this is doing is building the device driver table ...

A deice driver looks like this:

typedef struct {
  rtems_device_driver_entry initialization_entry; /* initialization procedure */
  rtems_device_driver_entry open_entry;        /* open request procedure */
  rtems_device_driver_entry close_entry;       /* close request procedure */
  rtems_device_driver_entry read_entry;        /* read request procedure */
  rtems_device_driver_entry write_entry;       /* write request procedure */
  rtems_device_driver_entry control_entry;     /* special functions procedure */
}   rtems_driver_address_table;

Problem

The problem which may be exceptionally simple is that when i build this i get the following error:

confdefs.h:568: error: too many initializers for 'rtems_driver_address_table'

From looking here this appears to be a problem compiling with an unspecified number of table elements. What I don't understand is that this is currently working in that if I specify the NULL_DRIVER_TABLE_ENTRY with 7 NULLs (the number i need), it will fail, but with 6 NULLs it works perfectly fine?

As far as i can tell there is no definition as to the size of this table or its elements? Any ideas?


Solution

  • So this was a silly mistake...

    The way this table works is that the NULL table entry:

    #define NULL_DRIVER_TABLE_ENTRY \
     { NULL, NULL, NULL, NULL, NULL, NULL}
    

    Is actually an entry in the array which corresponds to an rtems_driver_address_table. This driver has 6 elements and i was trying to have 7. The solution to this was to add an extra null entry as follows:

     rtems_driver_address_table Device_drivers[] = {
    
        ...
    
        #ifdef CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER
          NULL_DRIVER_TABLE_ENTRY,
          NULL_DRIVER_TABLE_ENTRY // Add extra entry here!
    
       ...
    
      };