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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:09:44+00:00 2026-06-12T04:09:44+00:00

recently I was browsing SO and I came across this topic , where Sam

  • 0

recently I was browsing SO and I came across this topic, where Sam Jansen is declaring a macro PACKED_STRUCT(name), but in code he is using it once with no arguments and once with the name argument supplied.

I tried to compile a similar sample progam with GCC 4.6.1 and I was surprised it compiled fine with no warnings at all (I was using -std=c99 -Wall -Wextra -pedantic command line switches).
However when I tried to make two argument macro and call it with less than two arguments, it did not work.

So my question is if this is a bug in GCC, or it is a feature of GCC, or it is defined somewhere in the standard, that it has to work like this?

According to this page in GCC’s documentation, this should not be possible.

  • 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-12T04:09:45+00:00Added an answer on June 12, 2026 at 4:09 am

    Read that page of GCC’s documentation again; it’s making a distinction between empty arguments and missing arguments. Given

    #define ONE(x)    one(x)
    #define TWO(x,y)  two(x,y)
    

    all of these are perfectly fine as far as the preprocessor is concerned (expansion in comment):

    ONE(1)    /* one(1)   */
    ONE()     /* one()    */
    TWO(1,2)  /* two(1,2) */
    TWO(1,)   /* two(1,)  */
    TWO(,2)   /* two(,2)  */
    TWO(,)    /* two(,)   */
    

    but this is not okay:

    TWO()     /* error: macro "TWO" requires 2 arguments, but only 1 given */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

recently, while working on a db2 -> oracle migration project, we came across this
Recently, I came across this one stone kills multiple birds framework - http://phonegap.com/ .
I was browsing Foursquare recently and they have this neat feature where you can
Recently, we discovered odd behavior in some old code. This code has worked for
I recently discovered the Emacs code browsing package (ECB) and it seems to be
I recently found some interesting macro while browsing random sources around the internet: #define
A client of mine recently came up with a few apps he came across
Recently I found a pretty graph when I was browsing the adminskins at ThemeForest
Recently, I was browsing through my copy of the C++ Pocket Reference from O'Reilly
I'm really new to programming, and creating programs. Recently I was browsing around iTunes

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.