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

  • SEARCH
  • Home
  • 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 7882309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:15:13+00:00 2026-06-03T04:15:13+00:00

This is some code I’m compiling on Linux: #include <net/if.h> int main() { struct

  • 0

This is some code I’m compiling on Linux:

#include <net/if.h>

int main() {
  struct ifreq ifr;
}

gcc test.c is fine.

gcc -std=gnu99 test.c is fine.

gcc -std=c99 test.c fails with the following error:

test.c: In function ‘main’:
test.c:4:16: error: storage size of ‘ifr’ isn’t known

What’s different about C99 that it doesn’t like the definition of struct ifreq in Linux?

  • 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-03T04:15:14+00:00Added an answer on June 3, 2026 at 4:15 am

    It’s a chain of consequences of preprocessing and GNU C vs C99.

    First up, net/if.h:

    1. net/if.h includes features.h
    2. Later on, it defines struct ifreq inside a #ifdef __USE_MISC block.

    So:

    1. What is __USE_MISC? — it is stuff common to BSD and System V
    2. Is it defined at this point? — We need to check that out in features.h

    So now, features.h:

    1. When you use --std=c99 GCC by default defines __STRICT_ANSI__ (since thats what C99 is)
    2. While preprocessing features.h, when __STRICT_ANSI__ is on, the BSD and System V features don’t kick in. i.e. __USE_MISC is left undefined.

    Back up to net/if.h: struct ifreq does not even exist after preprocessing! Therefore, the complaint about storage size.

    You can catch the whole story by doing:

    vimdiff <(cpp test.c --std=c99 -dD) <(cpp test.c --std=gnu99 -dD)
    

    or diff’ing them in any other way (like diff --side-by-side) instead of vimdiff.

    If you want this to cleanly compile with -std=c99, you must consider the inclusion of the _DEFAULT_SOURCE feature test macro (for glibc versions >= 2.19; for older glibc versions, use either _BSD_SOURCE or _SVID_SOURCE) so that the required functionality is enabled on top of what is offered by C99.

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

Sidebar

Related Questions

const static int foo = 42; I saw this in some code here on
I'm using this statement //some code int a[][]=new int[5000000][5000000]; //some code and running it
This is some code I found on the internet. I'm not sure how it
this is some code that SDL requires in visual studios 2005 in order for
I saw this in some code: $(<p/>).append(<div>something</div>).appendTo(body); and noticed that it automatically closed the
I recently came across this in some code - basically someone trying to create
I'm currently doing something like this in some code I'm working on right now:
Context I came across some code, like this: if( Some_Condition ) throw 0; I
I just found this in some old code, and I'm not sure what it
I have a java code that looks like this: //UI thread //Some code Job

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.