Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!hc!ames!killer!texbell!bigtex!milano!pp!riunite!rfg From: rfg@riunite.ACA.MCC.COM (Ron Guilmette) Newsgroups: comp.lang.c++ Subject: #once considered non-standard? Message-ID: <125@riunite.ACA.MCC.COM> Date: 20 Mar 89 17:34:50 GMT Reply-To: rfg@riunite.UUCP (Ron Guilmette) Organization: MCC Austin, Texas Lines: 40 In a private letter, Ken Yap writes: >Wouldn't #pragma once be more ANSI standard conforming? Assuming that >some distant day C++ becomes frozen into an ANSI standard... OK. Regarding #once, you suggested that it be #pragma once because C++ may be an ANSI standard someday. First note that this has nothing to do with either C or C++. It is strictly a preprocessor issue. Now I know that you are going to say that preprocessing is covered by the ANSI C standard, but the point is that my extension is useful & relevant for a preprocessor for either C or C++. Given that the #once extension can (and may) be used with C, one should ask how this problem should be solved in C. My background includes a lot of time dealing with the Ada language, in which compilers are *required* to ignore pragmas which they do not understand. While the ANSI C standard does not require that unrecognized #pragma's be ignored, this behaviour is at least allowed. Thus, #pragma once could have been used for my purpose, but I am afraid that when code which used it was ported to a new C/C++ compiler (and preprocessor) the #pragmas would be ignored. This would give users a false sense of security because no errors or warnings would be issued, but the code would be compiled (well, preprocessed) in the wrong way. I don't want anybody to get a false sense of security, so I designed the new preprocessing directive so that it should cause most standard preprocessors (which don't support #once) to scream bloody murder when they encounter this construct. That way, users will know exactly where the problem is right away. -- // Ron Guilmette - MCC - Experimental (parallel) Systems Kit Project // 3500 West Balcones Center Drive, Austin, TX 78759 - (512)338-3740 // ARPA: rfg@mcc.com // UUCP: {rutgers,uunet,gatech,ames,pyramid}!cs.utexas.edu!pp!rfg