3 ms·
I have actually run across code in the wild along the lines of: int foo() int x; int y; { return x + y; } Perfectly legal C, if not an old archaic
by hermitdev 7y ago
I have actually run across code in the wild along the lines of:
int foo()
int x;
int y;
{ return x + y; }
Perfectly legal C, if not an old archaic and seldom used syntax. I saw it in some proprietary code, so, no, I cannot provide a link. It was odd, but worked for what it was trying to do.
It pays to know the language you work in, not to write things like this, but to understand on the off chance you encounter it in the wild.
Edit, I may be wrong on the syntax, it might be:
int foo(x, y)
int x;
int y;
{ return x + y; }
I dont have the ISO spec in front of me, but one of these should work.
- deleted 7y ago[deleted]
- barrkel 7y agoThat's K&R C, predating ANSI C. It's not that uncommon if you're looking at long-lived codebases. Rather it should look like this: int foo(x, y) int x; int y; { return x + y; } x and y would be assumed to be int in the absence of the type specifiers, so in this case they're optional.
- klodolph 7y agoTo add to this, int is also default return type. foo(x, y) { return x + y; }