Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Question about #error Date: Thu, 28 Mar 2019 14:28:37 -0700 Organization: None to speak of Lines: 54 Message-ID: References: <9183709e-58d4-47b5-9e2b-781600729a55@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="8cfa11d3fa0097ca58f89eca347894b2"; logging-data="32278"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+X8XGoDk0lioHq1frKdy+I" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:qqHSVWhJF5n25cN0ini3T8SsDgE= sha1:06tofJY4aOr5TSVvGiCAvXkGZLo= Xref: csiph.com comp.lang.c:142569 Thiago Adams writes: > On Wednesday, March 27, 2019 at 1:06:47 PM UTC-3, Kenny McCormack wrote: >> (Using gcc on Linux) >> >> I always assumed that #error would abort the compilation right then and >> there, rather than try to continue and report other errors. Since, >> conceptually, pre-processing happens first before any "real" compilation, >> you would think that if the pre-processor hits a #error directive, it would >> abort there before any actual syntactual analysis was done. > > Compilers have a close relationship with the preprocessor, > but everyone (standard) wants to keep them separated. > > The C standards describes the compilation in phases as if they > were separated steps. In case the compiler want to do it together > it has to mimic the behavior of phases. > > > What is funny is that compiler configuration like pragma pack > and many others are done using preprocessor. > > How can a preprocessor be separated from compiler in this case? > (rhetorical question) I'll answer it anyway. If a #pragma has effects that can't happen before translation phase 7 (syntax and semantic analysis and translation), then some form of it has to appear in the output of the earlier phases, and be recognized by the later phases. It does seem odd that this kind of thing is done using preprocessor syntax. One possible reason is that it allows an implementation-defined #pragma to affect preprocessing. > I have suggested in this group that the preprocessor should > be moved to the compiler phase and this would bring many > advantages. > > Compatibly in this case could be done using compiler flags > and new code could take advantage of this modification. There's no requirement that the 8 translation phases have to be done separately, only that a compiler must behave as if they were. As long as the end result is the same, the preprocessor can already be part of the compiler. If the phases were changed as you suggest, how would token-pasting work? I'm not at all sure just what you're proposing, or how it differs from the current definition. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */