Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: [OT] Abusing GNU compiler and linker: Make the linker generate an array of function pointers

by kikuchiyo (Friar)
on Oct 19, 2019 at 17:54 UTC ( #11107709=note: print w/replies, xml ) Need Help??


in reply to [OT] Abusing GNU compiler and linker: Make the linker generate an array of function pointers

/*Being off topic in an OT thread...*/ the title of this writeup reminded me of this recent IOCCC winning entry: "Most in need of debugging", by Yusuke Endoh
  • Comment on Re: [OT] Abusing GNU compiler and linker: Make the linker generate an array of function pointers

Replies are listed 'Best First'.
Re^2: [OT] Abusing GNU compiler and linker: Make the linker generate an array of function pointers
by afoken (Canon) on Oct 20, 2019 at 00:50 UTC
    the title of this writeup reminded me of this recent IOCCC winning entry

    *g*

    I've hacked a working prototype module for internal discussion. The header file has about 300 lines of Doxygen documentation and about 30 lines of code, mainly function prototypes and macros. The source file has about 40 lines of code, plus a little bit of doxygen documentation.

    Compared with our other modules, the relation between documentation and code in the source file is normal, may be a little bit short, but the documentation of the header is unusually verbose. Typically, the doxygen lines are twice or three times the number of code lines.

    The prototype is still a little bit rough, it still needs some paranoia checks and some cleanly documented ways for advanced use of the mechanism. That will increase the code size by about 20 lines and the documentation by about 100 lines.

    So yes, some parts of the code may look like coming from the IOCCC, but it's only the code. The documentation explains what happens, why and how, as usual for our projects.


    In fact, I actually use code from an IOCCC winner at work:

    IOCCC winner 1984

    int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\ o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}

    It's in a presentation for interns and freshly hired people, on one of the first pages, right after a picture of the HGTTG with the "don't panic" in big friendly letters. That piece of code is a really good example of bad code, on many levels. What follows is an introduction to the way we write code and documentation, why and how we do it, which modules are a little bit special, common errors, trouble with legacy code, and how to debug.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2022-08-10 05:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?