switching C compiler causes: Error Initializer cannot be specified for a flexible array member
        Posted  
        
            by 
                user1054210
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user1054210
        
        
        
        Published on 2012-09-19T15:23:20Z
        Indexed on 
            2012/09/19
            15:38 UTC
        
        
        Read the original article
        Hit count: 325
        
compiler
I am trying to convert our code from one IDE to be used in a different one. The current one uses gcc which allows for this structure to be initialized from a variable array. The new tool does not use gcc gives me an error "Initializer cannot be specified for a flexible array member". So can someone help me understand how to set this up? Should I set up a blank array of variable size and then somewhere assign the #define array as seen below?
Here would be an example of the code…(this is current implementation current IDE)
In one header file that is Build switchable so we can build this on different hardware platforms we have the following #define
#define GPIOS  \ 
          /*     BANK, PIN, SPD,  MODE,…  */
      GPIOINIT(   A,   0,   2,   AIN,  …) \
      GPIOINIT(   A,   1,   2,   AIN,  …) \
      GPIOINTINIT(A,   2,   2,   AIN,  …) \
      .
      .
      .
Then in a different header file that is used in all builds we have
  PLATFORM_CONFIG_T g_platformConfig = {
          .name = {PLATFORM_NAME},
          (bunch of other stuff),
         .allGpios = {
                     GPIOS /* here I get the error */
         },
   };
So I am thinking I can make the error line a variable array and assign to it later in some other way? The problem is the actual array "GPIO" is of different types and pin orders on different designs are different.
© Stack Overflow or respective owner