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 9154207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:23:34+00:00 2026-06-17T12:23:34+00:00

I have an issue with SDCC. My code (which I am attempting to port

  • 0

I have an issue with SDCC. My code (which I am attempting to port from another compiler) uses structs with flexible array members. However, when I try to compile the following code:

/** header of string list */
typedef struct {
    int nCount;
    int nMemUsed;
    int nMemAvail;
} STRLIST_HEADER;

/** string list entry data type */
typedef struct {
    int nLen;
    char str[];
} STRLIST_ENTRY;

/** string list data type */
typedef struct {
    STRLIST_HEADER header;
    STRLIST_ENTRY entry[];
} STRLIST;                      // By the way, this is the line the error refers to.

int main()
{
    return 0;
}

SDCC gives the following error:

$ sdcc -mz80 -S --std-c99 test.c
test.c:18: warning 186: invalid use of structure with flexible array member
test.c:18: error 200: field 'entry' has incomplete type

What gives? This code compiles just fine in gcc, not to mention the other z80 compiler I’m using.

EDIT: I found this SDCC bug which seems to be related. Could someone explain if it is and how?

  • 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-17T12:23:35+00:00Added an answer on June 17, 2026 at 12:23 pm

    SDCC is right there, and gcc-4.6.2 does not compile it “just fine” either. Well, if you ask it to adhere to the standard pedantically.

    Compiling with -std=c99 -pedantic (or -std=c1x -pedantic), gcc emits

    warning: invalid use of structure with flexible array member
    

    and clang-3.0 behaves similarly, its warning is slightly more informative:

    warning: 'STRLIST_ENTRY' may not be used as an array element due to flexible array member
    

    The standard prohibits that in 6.7.2.1 (3):

    A structure or union shall not contain a member with incomplete or function type (hence, a structure shall not contain an instance of itself, but may contain a pointer to an instance of itself), except that the last member of a structure with more than one named member may have incomplete array type; such a structure (and any union containing, possibly recursively, a member that is such a structure) shall not be a member of a structure or an element of an array.

    (emphasis is mine)

    gcc and clang allow having structs with flexible array members as members of structs or arrays as an extension. The standard prohibits that, so code using that is not portable, and every compiler is within its rights to reject the code.

    The linked issue is not relevant, it is about not giving a warning if a struct with a flexible array member is instantiated as an automatic, which isn’t allowed per the standard (but accepted by SDCC and others as an extension).

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

Sidebar

Related Questions

Much of my sql code is generated (from POD). Now i have issue where
I have an issue of alphabetically sorting the contacts picked from the address book
I have an issue which I could not find answer for across the web.
I have an issue while getting the file name with out extension from a
I have an issue. I am getting data from a MySQL database, and make
Hi i have issue here of calling another controller action to send an mail,
i have issue regarding Paging using filterexpression. here's the piece of code for filtering
I have issue with using utf-8 with JDOM parser. My code won't write encoded
I have issue where i want to create Dynamic function which will do some
I have issue with EF code first, when I am trying to insert a

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.