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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:29:11+00:00 2026-05-21T03:29:11+00:00

In C99, we have compound literals, and they can be passed to functions as

  • 0

In C99, we have compound literals, and they can be passed to functions as in:

f((int[2]){ 1, 2 });

However, if f is not a function but rather a function-like macro, gcc barfs on this due to the preprocessor parsing it not as one argument but as two arguments, “(int[2]){ 1” and “2 }“.

Is this a bug in gcc or in the C standard? If it’s the latter, that pretty much rules out all transparent use of function-like macros, which seems like a huge defect…

Edit: As an example, one would expect the following to be a conforming program fragment:

fgetc((FILE *[2]){ f1, f2 }[i]);

But since fgetc could be implemented as a macro (albeit being required to protect its argument and not evaluate it more than once), this code would actually be incorrect. That seems surprising to me.

  • 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-05-21T03:29:12+00:00Added an answer on May 21, 2026 at 3:29 am

    This “bug” has existed in the standard since C89:

    #include <stdio.h>
    
    void function(int a) {
        printf("%d\n", a);
    }
    
    #define macro(a) do { printf("%d\n", a); } while (0)
    
    int main() {
        function(1 ? 1, 2: 3); /* comma operator */
        macro(1 ? 1, 2: 3);    /* macro argument separator - invalid code */
        return 0;
    }
    

    I haven’t actually looked through the standard to check this parse, I’ve taken gcc’s word for it, but informally the need for a matching : to each ? trumps both operator precedence and argument list syntax to make the first statement work. No such luck with the second.

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

Sidebar

Related Questions

I read in the c99 Standard: -remove implicit function declaration, -remove implicit int. But
I have a c99 function that uses openmp, which works as expected. I also
Let's say I have a variadic function foo(int tmp, ...) , when calling foo
Lets say i have two inline functions in my header file: inline int foo()
I have some C programs without any explicit return from main, like this: int
Using GCC and C99 mode, I have a function declared as: void func(float *X);
I have the following code which you can try using c99 filename.c; ./a.out #include
We develop some project in plain C (C99). But, we have one library as
I have a function as follows: -(int)ladderCalc:(NSArray*)amounts percentages:(NSArray*)percentages amount:(int)amount { // Do some stuff
compiling with gcc C99 I have been using enums for a while now. However,

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.