What version/syntax is this piece of C code?

I was doing some research on some closed source codecs and was given this code.

That P3() seems not ANSI-C. What version is that from?

Thank you!

[code[
void data_dec P1((c, a, str), codec c, codec_byte * a, in_stream * str)
{
}

[/code]
What P3 ?

Also, macros are typically written in upper case.
So if something looks weird, be prepared for trying to dig through some pre-processor abuse.
Oh typo.
I meant P1((c,a,str),.

closed account (E0p9LyTq)
Looks like some weird variant of older K&R function declaration.

https://stackoverflow.com/questions/1630631/alternative-kr-c-syntax-for-function-declaration-versus-prototypes
Thank you FurryGuy.

I do see a define called,
#define P1(a, b, c, d) a b; c; d;

How would that be translateed to modern ANSI-C?
Last edited on
It probably was P3 (meaning three parameters) and defined something like this:

1
2
3
4
5
6
7
8
9
#ifdef ANSI
#define P3(vars, x, y, z)  (x, y, z)
#else
#define P3(vars, x, y, z)  vars  x; y; z;
#endif

void data_dec P3((c, a, str), codec c, codec_byte * a, in_stream * str)
{
}

Using gcc -E yields

1
2
3
4
5
6
7
8
9
// If ANSI is defined:
void data_dec (codec c, codec_byte * a, in_stream * str)
{
}

// If ANSI isn't defined
void data_dec (c, a, str) codec c; codec_byte * a; in_stream * str;
{
}

Thank you dutch.
I didn't see your post before I posted mine. Apparently it is called P1. I thought it probably was called P3 since it would be hard-coded for three parameters and you would need different ones for different numbers of parameters.
I see. If it's an old version/style in C then i see no need to dig at that.
Thank you all!
Topic archived. No new replies allowed.