What is Wrong With this Picture?

I’ve just found a number of subroutines defined this way in the code that I’m working on.

I discovered the problem because I started getting errors about “too many parameters”. I knew what the problem was (the empty prototype) but it took a couple of minutes of head-scratching before I realised why it had been working before my changes.

Then I realised.

I have a dislike of “unnecessary” &s on subroutine calls. So almost without realising, I had removed them from the calls to these functions.

A few lessons have been learned.

Lesson 1 (for the original author of this code): Prototypes will trip you up. Do not use them.

Lesson 2 (for me): Ampersands aren’t always as pointless as they appear. They may be masking bugs in the code.


Posted

in

by

Comments

2 responses to “What is Wrong With this Picture?”

  1. burakgursoy.myopenid.com Avatar
    burakgursoy.myopenid.com

    Funny. I didn’t know that “&” can bypass prototypes.

  2. Dave Cross Avatar
    Dave Cross

    Neither, apparently, did the person who originally wrote that code ๐Ÿ™‚

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.