Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #142569

Re: Question about #error

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Question about #error
Date 2019-03-28 14:28 -0700
Organization None to speak of
Message-ID <lno95uadtm.fsf@kst-u.example.com> (permalink)
References <q7g72f$59q$1@news.xmission.com> <9183709e-58d4-47b5-9e2b-781600729a55@googlegroups.com>

Show all headers | View raw


Thiago Adams <thiago.adams@gmail.com> 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  <http://www.ghoti.net/~kst>
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Question about #error gazelle@shell.xmission.com (Kenny McCormack) - 2019-03-27 16:06 +0000
  Re: Question about #error Chad <cdalten@gmail.com> - 2019-03-27 10:21 -0700
  Re: Question about #error scott@slp53.sl.home (Scott Lurndal) - 2019-03-27 17:35 +0000
    Re: Question about #error nobody@example.org (Scott) - 2019-03-28 04:33 +0000
      Re: Question about #error Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-04-07 00:15 -0700
        Re: Question about #error gazelle@shell.xmission.com (Kenny McCormack) - 2019-04-07 10:22 +0000
          Re: Question about #error nobody@example.org (Scott) - 2019-04-07 17:10 +0000
  Re: Question about #error Bart <bc@freeuk.com> - 2019-03-27 17:52 +0000
  Re: Question about #error luser droog <luser.droog@gmail.com> - 2019-03-27 12:36 -0700
    Re: Question about #error luser droog <luser.droog@gmail.com> - 2019-03-27 12:47 -0700
  Re: Question about #error John Bode <jfbode1029@gmail.com> - 2019-03-27 14:28 -0700
    Re: Question about #error David Brown <david.brown@hesbynett.no> - 2019-03-27 22:38 +0100
  Re: Question about #error Thiago Adams <thiago.adams@gmail.com> - 2019-03-28 13:59 -0700
    Re: Question about #error Keith Thompson <kst-u@mib.org> - 2019-03-28 14:28 -0700
      Re: Question about #error Thiago Adams <thiago.adams@gmail.com> - 2019-03-29 07:09 -0700
        Re: Question about #error James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-03-29 08:05 -0700
          Re: Question about #error Thiago Adams <thiago.adams@gmail.com> - 2019-03-29 12:08 -0700
            Re: Question about #error Thiago Adams <thiago.adams@gmail.com> - 2019-03-29 12:15 -0700
            Re: Question about #error Thiago Adams <thiago.adams@gmail.com> - 2019-03-29 12:53 -0700
          Re: Question about #error Thiago Adams <thiago.adams@gmail.com> - 2019-03-30 14:40 -0700
            Re: Question about #error Keith Thompson <kst-u@mib.org> - 2019-03-30 15:19 -0700
              Re: Question about #error Thiago Adams <thiago.adams@gmail.com> - 2019-03-30 16:17 -0700
                Re: Question about #error scott@slp53.sl.home (Scott Lurndal) - 2019-03-31 19:12 +0000
                Re: Question about #error Thiago Adams <thiago.adams@gmail.com> - 2019-04-01 04:32 -0700
              Re: Question about #error David Brown <david.brown@hesbynett.no> - 2019-03-31 20:17 +0200
                Re: Question about #error Richard Damon <Richard@Damon-Family.org> - 2019-03-31 15:09 -0400
                Re: Question about #error David Brown <david.brown@hesbynett.no> - 2019-03-31 21:46 +0200
                Re: Question about #error Thiago Adams <thiago.adams@gmail.com> - 2019-04-01 04:36 -0700
            Re: Question about #error James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-04-02 17:47 -0700
              Re: Question about #error Thiago Adams <thiago.adams@gmail.com> - 2019-04-03 05:31 -0700
                Re: Question about #error James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-04-03 06:46 -0700
                Re: Question about #error Thiago Adams <thiago.adams@gmail.com> - 2019-04-03 07:44 -0700
                Re: Question about #error Thiago Adams <thiago.adams@gmail.com> - 2019-04-03 09:46 -0700
    Re: Question about #error scott@slp53.sl.home (Scott Lurndal) - 2019-03-28 21:29 +0000
    Re: Question about #error Thiago Adams <thiago.adams@gmail.com> - 2019-03-29 07:32 -0700

csiph-web