RE: A little bit of C fun...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Oh, no... I'm dumb.

typedef struct {
        int x;
} b;

int a(b *param)
{
        return printf("%d\n", b->x);
}

int print_number(int c)
{
        return a(&(b){c});
}

-----Original Message-----
From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On Behalf Of Austin, Alex
Sent: Wednesday, October 22, 2008 3:13 PM
To: John Carter; me22
Cc: gcc-help@xxxxxxxxxxx
Subject: RE: A little bit of C fun...

A guess:
b is a type, and a is a function that takes a pointer to a function that returns b?

-----Original Message-----
From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On Behalf Of John Carter
Sent: Wednesday, October 22, 2008 2:38 PM
To: me22
Cc: gcc-help@xxxxxxxxxxx
Subject: Re: A little bit of C fun...

On Wed, 22 Oct 2008, me22 wrote:

> Use the preprocessor.  Otherwise you can't get braces inside parens.

Nope. I didn't use preprocessor. But warped kudos to you for thinking
of it.

Since you are all struggling, I'll make it easier for you.

I shorten it by one character....
    a(&(b){})

... (but then it does something subtly more that the previous
one...oooh I'm evil!)


John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : john.carter@xxxxxxxxxx
New Zealand



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux