home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmb
- From: tmb@arolla.idiap.ch (Thomas M. Breuel)
- Newsgroups: comp.lang.c++
- Subject: Re: zero-length datatype
- Message-ID: <TMB.92Sep11211332@arolla.idiap.ch>
- Date: 12 Sep 92 01:13:32 GMT
- References: <TMB.92Sep8141523@arolla.idiap.ch> <4947@holden.lulea.trab.se>
- <HAYDENS.92Sep9215705@bullwinkle.juliet.ll.mit.edu>
- <TMB.92Sep10120206@arolla.idiap.ch> <23650@alice.att.com>
- Sender: news@ai.mit.edu
- Reply-To: tmb@idiap.ch
- Distribution: comp
- Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
- Perceptive)
- Lines: 34
- In-reply-to: ark@alice.att.com's message of 10 Sep 92 17:36:24 GMT
-
- In article <23650@alice.att.com> ark@alice.att.com (Andrew Koenig) writes:
-
- There is one problem with `void' as a true datatype that I have not
- been able to solve: ISO C says that
-
- void f(void);
-
- is a function with no arguments at all and C++ therefore follows suit.
- Making void into a true type would therefore require some compatibility
- warts; it is not clear exactly what would be necessary or what effect it
- would have on the rest of the language.
-
- I mentioned this in my posting; I don't think this is a serious
- problem, for the following reasons.
-
- To remain compatible with C, you can interpret the above prototype as
- meaning either "a function taking no arguments" or as "a function
- taking exactly one argument of type 'void'". That is, it would be
- legal to call the above function as "f()" or "f(void())". Since there
- is no actual data being passed and no actual dereferencing happening,
- this is harmless.
-
- Compiler writers might be encouraged to issue a warning when a
- declaration of "void f(void);" occurs in the C++ language context
- (rather than inside an 'extern "C"') _and_ the function is actually
- being used without arguments. Likewise, using any kind of "void" type
- cinside the C language context should be flagged as an error.
-
- Maybe the interpretation of "void f(void)" as a function taking no
- arguments could eventually be phased out in the C++ language context.
- After all, K&R style declarations and definitions are also valid in
- ISO C but not in C++.
-
- Thomas.
-