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


Groups > comp.lang.c++ > #8557

Re: Macro does not work in source code.

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: Macro does not work in source code.
Date 2011-08-08 09:15 +1200
Message-ID <9a8dk5Fef9U2@mid.individual.net> (permalink)
References (7 earlier) <j14mc6$3i9$2@dont-email.me> <c9fec$4e364ea1$506c0d9c$5748@news.chello.at> <j15n3o$8s6$1@dont-email.me> <ed28d956-8d89-4a3f-829f-6f8dc50ad436@fq4g2000vbb.googlegroups.com> <j1mtq7$h59$1@dont-email.me>

Show all headers | View raw


On 08/ 8/11 08:50 AM, Alf P. Steinbach wrote:
> On 07.08.2011 20:00, James Kanze wrote:
>> On Aug 1, 9:11 am, "Alf P. Steinbach"
>> <alf.p.steinbach:use...@gmail.com>   wrote:
>>> On 01.08.2011 08:58, Paul Brettschneider wrote:
>>
>>>> Especially in this
>>>> case were it was suggested up-thread to use include guards *and* the
>>>> #pragma. That's one more line for nothing. Old cruft like this should be
>>>> supported for compatibility reasons, but also deprecated to make a point.
>>
>>> On the contrary, "#pragma once" is probably what one should use for new
>>> code  --  IN SPITE OF NOT BEING FORMALLY STANDARD. ;-)
>>
>> Only if you don't care if your code works on machines other than
>> Windows and Linux.
>
> I think, if one needs to support a compiler that doesn't support
> `#pragma once`, then one is in about the same kind of boat as one who is
> targeting a 16-bit char system: one is not writing portable code.
>
> So, big difference between formal and practice. :-)
>
> But here's the crucial thing: if up-front generation of include guards
> is feasible, and it is, then for those special compilers (like 16-bit
> Digital Signal Processor compiler) it's no big deal to preprocess the
> source replacing `#pragma once` with traditional include guards.

Well my day to day compiler (Sun CC) does not use `#pragma once` and I 
have never seen it used in Unix, Linux or embedded system headers.

In a way, `#pragma once` is an anachronism.  The preprocessor can keep 
track of open headers with include guards and not reopen the file.  Both 
Sun CC and gcc appear to be doing this.

It is probably a worthwhile optimisation, I bet most of the headers 
encountered in a typical build are system or third party library headers 
that do no use `#pragma once`.

-- 
Ian Collins

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


Thread

Macro does not work in source code. Nephi Immortal <immortalnephi@gmail.com> - 2011-07-28 17:36 -0700
  Re: Macro does not work in source code. Sam <sam@email-scan.com> - 2011-07-28 20:41 -0500
  Re: Macro does not work in source code. red floyd <no.spam.here@its.invalid> - 2011-07-28 23:45 -0700
    Re: Macro does not work in source code. Juha Nieminen <nospam@thanks.invalid> - 2011-07-29 10:01 +0000
      Re: Macro does not work in source code. "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-07-29 13:31 +0200
  Re: Macro does not work in source code. MJ_India <mail.mohitjain@gmail.com> - 2011-07-29 23:41 -0700
    Re: Macro does not work in source code. Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-07-30 12:58 +0000
      Re: Macro does not work in source code. Brian Casiello <bcasiello@gmail.com> - 2011-07-30 11:39 -0400
        Re: Macro does not work in source code. Paul Brettschneider <paul.brettschneider@yahoo.fr> - 2011-07-31 18:12 +0200
          Re: Macro does not work in source code. Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-07-31 18:30 +0000
            Re: Macro does not work in source code. "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-08-01 00:48 +0200
              Re: Macro does not work in source code. "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-08-01 00:52 +0200
                Re: Macro does not work in source code. Paul Brettschneider <paul.brettschneider@yahoo.fr> - 2011-08-01 08:58 +0200
                Re: Macro does not work in source code. "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-08-01 10:11 +0200
                Re: Macro does not work in source code. James Kanze <james.kanze@gmail.com> - 2011-08-07 11:00 -0700
                Re: Macro does not work in source code. "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-08-07 22:50 +0200
                Re: Macro does not work in source code. Ian Collins <ian-news@hotmail.com> - 2011-08-08 09:15 +1200
                Re: Macro does not work in source code. Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-01 12:09 +0000
                Re: Macro does not work in source code. Miles Bader <miles@gnu.org> - 2011-08-02 14:53 +0900
              Re: Macro does not work in source code. Ian Collins <ian-news@hotmail.com> - 2011-08-01 10:55 +1200
      Re: Macro does not work in source code. James Kanze <james.kanze@gmail.com> - 2011-08-07 10:47 -0700
        Re: Macro does not work in source code. Marc <marc.glisse@gmail.com> - 2011-08-07 18:13 +0000

csiph-web