rfg@riunite.ACA.MCC.COM (Ron Guilmette) (03/21/89)
In a private letter, Ken Yap <ken@cs.rochester.edu> 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
henry@utzoo.uucp (Henry Spencer) (03/22/89)
In article <125@riunite.ACA.MCC.COM> rfg@riunite.UUCP (Ron Guilmette) writes: >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... That is an accident of the implementation; the preprocessor constructs are *PART OF THE LANGUAGE* for any practical purposes. Many compilers do not use a separate preprocessor at all. -- Welcome to Mars! Your | Henry Spencer at U of Toronto Zoology passport and visa, comrade? | uunet!attcan!utzoo!henry henry@zoo.toronto.edu