Richard A. O'Keefe wrote:
I made two claims, one of which was wrong and one of which was right:

(1) defining a macro with () was not defined in C89 [wrong]. (2) invoking a macro with () was not defined in C89 [right].

Recall that
    > Allowing an empty argument list for a function-like macro was a
    > CHANGE from C89 to C99.  It was proposed by Fred J. Tydeman on 1995-01-09.

So we had the more than odd situation that apparently you were allowed
to define an argumentless function-like macro but you weren't allowed to
invoke it with no arguments.
This is the question at hand: was it a change, or was it not?
Terry Colligan <[EMAIL PROTECTED]>, who should
speak with authority, tries to have it both ways:

        It is (and was) clearly necessary to allow macros to replace
        functions, something which has been in C for a long time.
        
True, but not really relevant.  It was NOT necessary to allow an
argumentless DEFINITION to get that effect.  If empty arguments
had been legal, then

    #define foobar(dummy) (1+1)
    ...
        dummy()

would have been legal.
Was that the example you meant to use?  Did you mean to attempt to
use the macro foobar with no arguments (which is illegal, as the number
of arguments is required to match the number of parameters)?  If this
is not a typo, I'm missing something, as I don't see any macro called
dummy defined above.
          It *is* clearly in the X3.159-1989 standard, in section 3.8.3.
Is there any way you could talk ANSI into making the old superseded standard
available on the web?  As I noted, I've spent several hundred dollars over
the years buying copies that have subsequently disappeared from my office,
so I can't check this for myself.

        > He was talking about empty *actual parameters*, but the two are 
related.
        > There is no point in writing
        >     #define FOO() ...
        > unless you mean to invoke it as
        >     ... FOO() ...
        
          Yes! Exactly.
        
        > and the latter really was undefined behaviour caught by at least one
        > compiler.
        
(A)       Then that compiler was not conforming to the 1989 standard.
        
        ...     

(B)       What C99 upgraded from a common extension to part of the standard was
          the possiblility of empty actual arguments.

And that's where he tries to have it both ways.
No. In C90, it was legal to have an empty list of arguments, but in C99 it is also legal to have a non-empty list of arguments, one or more of which is itself empty. (C90 does not permit an argument to be empty.)

(A) is a statement that "the latter" (that is, an INVOCATION of a macro
with an empty argument) conformed.
(B) is a statement that it didn't (it used to be a "common extension",
like three-argument main(), not "part of the standard").
No; B refers to something else, which is the new feature in C99 of allowing
#define binary(a,b)
binary(2,)
i.e., where there are two arguments but the second argument is empty.

          The description is relentlessly and excessively terse, but that was 
one
          of our goals -- to be as brief as possible so as to reduce the chance 
of
          the standard being self-conflicting.  Personally, I think we went 
overboard
          and made the standard much harder to read as a result.
        
The C89 standard wasn't a bad read.  In fact, compared with the C++
standard, it was an *excellent* read.  (Mind you, compared with
the C++ standard, what isn't?)
There are probably other lists for language wars.  I use both C and C++ as
appropriate, and don't find either standard particularly more or less readable
than the other.
        > So it may be, but you still weren't allowed to do it in C89.
        
          Yes, you were -- at least in any conforming compiler.
        
No, you have confirmed, in your statement

(B)       What C99 upgraded from a common extension to part of the standard was
          the possiblility of empty actual arguments.

that invoking a macro with empty actual parameters was *not* required of
conforming compilers.

Possibly you have misread B to be a contradiction to A, instead of realizing that it must have been referring to empty arguments and not to an empty argument _list_.
Thank you for confirming that.

I'm very confident that it was not confirmed, and reasonably confident that it is not true.

-- James

_______________________________________________
splint-discuss mailing list
[email protected]
http://www.cs.Virginia.EDU/mailman-2.1.5/listinfo/splint-discuss

Reply via email to