Re: C No Operation doubt

Discussion in 'C Programming' started by Keith Thompson, May 25, 2014.

  1. All four will work, but I'd argue that the last one is an abuse of NULL,
    which is specifically a null pointer constant. (Ada uses the "null"
    keyword both for null pointers and for null statements, but of course
    that's a different language.)

    If I saw "NULL;" used as a do-nothing statement, I'd have to stop and
    wonder why the author didn't just write ";".
    Keith Thompson, May 25, 2014
    1. Advertisements

  2. That's what I like about it ;-)
    Kind of jumps out at you. A lot harder to miss when reading than
    just an isolated semicolon.[/QUOTE]

    Jumping out at you is great; it's the confusing things it then
    shouts at me that make me uneasy.

    If I see


    in a C program, it means either that the author knows that NULL is
    an expression with no side effects that can reasonably be used in an
    expression stastement and will result in generated code equivalent
    to an empty statement *or* that the author thinks NULL is how you
    write a null statement in C. I'd rather not have to spend too much
    time guessing which.

    There's always:

    /* nothing */;
    Keith Thompson, May 28, 2014
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.