[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::c_plus_plus

Title:C++
Notice:Read 1.* and use keywords (e.g. SHOW KEY/FULL KIT_CXX_VAX_VMS)
Moderator:DECCXX::AMARTIN
Created:Fri Nov 06 1987
Last Modified:Thu Jun 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3604
Total number of notes:18242

3469.0. "a compilation problem related to void" by TUXEDO::LU () Thu Feb 27 1997 10:50

The following snippet of code was compiled on Digital Unix V3.2 using DEC C++ V5.4-006 compiler.

% cat foo.cxx
typedef void MY_VOID;
MY_VOID foo(MY_VOID);

bar()
{
    foo();
    return 0;
}

MY_VOID foo(MY_VOID)
{
}

% cxx -c -g foo.cxx
cxx: Error: junk1.cxx, link 6: In this statement, "foo()" supplies 0 arguments, but 1 is expected.
...

The code compiles just fine if I replace MY_VOID with void.
Any idea as to whether it's a bug?

-James
T.RTitleUserPersonal
Name
DateLines
3469.1MOIRA::FAIMANWandrer, du M�der, du bist zu HausThu Feb 27 1997 11:1211
ARM �8.2.5 and draft standard �8.3.5 state

	The parameter list (void) is equivalent to the empty parameter list.

Note that they do *not* say that "a parameter list containing only a single
parameter declaration which declares a parameter whose type is void is
equivalent to the empty parameter list."

I.e., in this construct "void" is a keyword, not a type name.

	-Neil
3469.2void related compilation problemTUXEDO::LUThu Feb 27 1997 14:487
Appreciate the effort for looking up the C++ references.

I am actually more perplexed than before so bear with me a little.
In my little example, if DECCXX treats the void as a keywork and not a type name then why
it thinks the function actually has ONE parameter?

-James  
3469.3does this answer your question?MUCTEC::BECKERHartmut B., VMS & Languages, MunichFri Feb 28 1997 06:1228
re .2

In C (and C++) you only need a type specifier in the function declaration, you
don't need a mparameter name. In C++ even in the definition, you don't need the
parameter name, if it isn't referenced. But you have to supply an argument
when you call it. For example

void foo (int);		// declaration, only type specifier

void bar (void) {
	foo (1);	// actual call, argument necessary
}

void foo (int) {	// definition, parameter not referenced
}

compiles with C++ (doesn't with C).

If you call foo the compiler expects an argument. As you can see this isn't
different from your example. Your type is MY_VOID, hence you have to supply an
argument of type MY_VOID (which can't be done, but that's another story).

But that's not what I think you wanted. Maybe a '#define MY_VOID void' can do
the job for you.

Hope this is an answer to what I think was your question,
Hartmut
    
3469.4yes, my question has been answeredTUXEDO::LUFri Feb 28 1997 13:075
Thanks for both re. 1 and 3. Your answers lead to my conclustion that it's a Microsoft-ism,
and I am not sure if it's a MS compiler's bug or feature. In any event, appreciate for the time and effort
for answering the question.

-James
3469.5Microsoft extension, supported in V6.0DECCXX::AMARTINAlan H. MartinFri Feb 28 1997 15:2818
Re .4:

>Thanks for both re. 1 and 3. Your answers lead to my conclustion that it's a
>Microsoft-ism, and I am not sure if it's a MS compiler's bug or feature.  ...

It's a non-standard extension (and I bet Microsoft never knew they were
extending the language).

DEC C++ V6.0 will accept that use of a typedefed void under -ms mode.

(However, it will possibly warn about the lack of a return type in bar's
definition, since ANSI requires that):

"void.cxx", line 4: warning: omission of explicit type is nonstandard ("int"
          assumed)
  bar()
  ^
				/AHM
3469.6the release time frame for DEC C++ V6.0TUXEDO::LUMon Mar 03 1997 10:236
Re .5:

It's wonderful that DEC C++ V6.0 will support this additional MS dialect.
What's the release time frame for V6.0?

-James
3469.7Schedule info for V6.0DECCXX::MITCHELLMon Mar 03 1997 12:132
On Digital UNIX, we expect to start V6.0 alpha test in
Aug-97 and beta test in Sep-97.