Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8547085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:11:24+00:00 2026-06-11T13:11:24+00:00

I am trying to convert our code from one IDE to be used in

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:11:26+00:00Added an answer on June 11, 2026 at 1:11 pm

    Initializing flexible array members with an aggregate is a gcc extension. The good news is that since you are allocating the g_platformConfig statically, you do not need that member to be a flexible array: you can go for a fixed-size array instead.

    It is very likely that somewhere in your code you have a definition of the constant that says how many items there are in the GPIOS array (otherwise, you’d need to rely on a “sentinel” value of sorts, similar to null terminator of C strings, to know where legitimate GPIOS values end). If you have that constant already, modify the definition of allGpios to be

    gpoinit_t allGpios[GPIO_COUNT]; // regular array
    

    instead of

    gpoinit_t allGpios[]; // flexible array
    

    With this change in place, your code should compile correctly.

    If you do not have a GPIO_COUNT constant, consider either adding one, or introducing a MAX_GPIO value limiting the number of items in allGpios. Either way, converting the array to a non-flexible one will fix the error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to convert my shop from using VSS to TFS. Our current
Trying to convert this c code into MIPS and run it in SPIM. int
Trying to convert output from a rest_client GET to the characters that are represented
im trying to convert a date format into a new format in this example
I am writing an application which tests email addresses, for one part of this
I'm using Entity Framework code first and pulling some data back from our database.
I'm trying to convert our existing codebase to a more correct approach. Our existing
I'm trying to convert our existing JSF application for mobile devices by integrating jquery
I'm attempting to use the XML::Simple CPAN module to convert output from our database
I'm trying convert all special chars into HTML safe entities on their way into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.