This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A little bit of C fun...


On Wed, Oct 22, 2008 at 00:44, John Carter <john.carter@tait.co.nz> wrote:
>
> Consider for a moment this program excerpt...
>  a(&(b){c})
>
> Is this valid C++?
>
> Is this valid C?
>
> What would you need to do to get this to compile?
>

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

#define c return 0;
#define b d)
#define a(T) int d; if (T

int main() {
    a(&(b){c})
}

> What does it do?
>

Whatever you want.

> Could it be tweaked into something useful? (apart from using it to
> hurt people's brains with.)
>

No.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]