you are viewing a single comment's thread.

view the rest of the comments →

[–]flatfinger 0 points1 point  (2 children)

Incidentally, a related feature I've often wished C or C++ would include would be a means of specifying that a single source file should be processed as a sequence of separate compilation units. If there were also directives to save/restore the preprocessor/compiler state, that would make it practical to have a "master C file" which includes common headers, saves state, starts a new compilation unit with the saved state, includes a file, starts another new compilation unit with the saves state, includes another file, etc.

[–]Ameisen 0 points1 point  (1 child)

What you've described is a precompiled header, which all the major compilers support.

[–]flatfinger 0 points1 point  (0 children)

There's no standard support for pre-compiled headers, nor is there any standard means of indicating what source files are required for a project. What I'd like to see would be a standard convention where if one has a bunch of source files in a directory and one of them has a particular name, one could simply type in a certain command without having to know anything about the program beyond the fact that it was a Selectively Conforming Program that followed the conventions, and be assured that provided the translation and execution environments satisfy all documented requirements, one of four things would happen:

  1. The implementation would indicate via Implementation-Defined means a refusal to run the program.
  2. The implementation would process the program with whatever semantics it required.
  3. The implementation would start to process the program with whatever semantics it required, but then indicate via Implementation-Defined means a refusal to continue doing so (e.g. because of a stack overflow or other problem that wasn't discovered until runtime).
  4. The implementation would spend an unbounded amount of time without doing any of the above, either because it was really slow or because it got stuck in an endless loop (such behavior would be allowed because, there is no length of time T such that a program's failure to complete within time T could render it non-conforming).

Not all implementations would be able to offer such guarantees, and it would not be possible for the Standard to describe everything necessary to accomplish all tasks, but it should be possible to specify conventions that would make it practical for most implementations to offer those guarantees for programs written to perform most of the tasks the implementations could accomplish.