Comment by kazinator
2 days ago
My position doesn't revolve around the mechanics of preprocessing. Say we have somehow given the implementation a translation unit which has #include <winkle.h>. Say we did not give the implementation a file winkle.h; we did not place such a file in any of the places where it searches for include files.
OK, now suppose that the implementation resolves #include <winkle.h> and replaces it with tokens.
The subsequent processing is what my position is concerned with.
My position is that since the standard doesn't define what those tokens are, the behavior is not defined.
In other words, a conforming implementation can respond #include <winkle.h> with any behavior whatsoever.
- It can diagnose it as not being found.
- It can replace it with the token __wipe_current_directory which that same implementation then understands as a compile-time instruction to wipe the current direcctory.
- Or any other possibility at all.
This all has to do with the fact that the header is not required to exist, but may exist, and if it does exit, it may have any contents whatsoever, including non-portable contents which that implementation understands which do weird things.
It is not required to document any of it, but if it does, that constitutes a documented extension.
A conforming implementation can support a program like this:
#include <pascal.h>
program HelloWorld;
begin
WriteLn('Hello, World!');
end.
All that <pascal.h> has to do is regurgitate a token like __pascal_mode. This token is procesed by translation phase 7, which tells the implementation to start parsing Pascal, as an extension.
No comments yet
Contribute on Hacker News ↗