Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: help porting a line of bitwise C code to perl

by missingthepoint (Friar)
on Sep 05, 2008 at 12:26 UTC ( [id://709256]=note: print w/replies, xml ) Need Help??


in reply to Re: help porting a line of bitwise C code to perl
in thread help porting a line of bitwise C code to perl

was that form ever legal C?

Yeah, it was (for certain values of 'legal'). That form of function prototype is known as 'K&R style'... There are - in the broadest possible terms - two versions of C. The first is usually called 'K&R C', from the initials of the authors of the canonical textbook (The C Programming Language). The second is called 'ANSI C' or 'ISO C', from the initials of the American and international standards bodies who, well, standardized the language.

Anyway, when ANSI standardized the C language it got a major overhaul, which included a new form of function declaration. The old form will still compile on lots of compilers, but the new form (usually called 'ANSI style') is much better.


email: perl -e 'print reverse map { chr( ord($_)-1 ) } split //, "\x0bufo/hojsfufqAofc";'
  • Comment on Re^2: help porting a line of bitwise C code to perl

Replies are listed 'Best First'.
Re^3: help porting a line of bitwise C code to perl
by BrowserUk (Patriarch) on Sep 05, 2008 at 16:23 UTC
    from the initials of the authors of the canonical textbook (The C Programming Language).

    Yes. My copy sits on the shelf above my computer. It has a loose front cover, is a faded yellow color, has the ISBN number 9-130110163-3 and dates from 1978.

    And on page 218/section 18.4 External definitions it give the following set of possibilities:

    program: external-definition external-definition program external definition: function-definition data-definition function-definition: type-specifier(opt) function-declarator function-body function-declarator declarator ( parameter-list(opt) ) parameter-list: identfier identifier , parameter-list function-body: type-decl-list function-statement function-statement: { declaration-list(opt) statement-list }

    I don't think you you'll find a much earlier revision than my copy, indeed I can't find any sign that it is a revised edition at all, but I can't see any interpretation of the above, that means that:

    unsigned long func (c) unsigned char *c;

    was ever a legal function declaration.

    There are certainly no examples in the book that look like that, though there are precious few examples of function declaration. I've been doing C a long time and I've always declared function parameters inside the parens. I well remember the old DECUS compiler used to permit some extraordinary code, which why it was so favoured by the Obfuscated-C entrants, but I still do not recall seeing people use the above declaration form.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://709256]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-19 20:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found