tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: #pragma once



Mouse wrote in
 <202210152055.QAA24709%Stone.Rodents-Montreal.ORG@localhost>:
 |> Traditionally to avoid problems with repeated inclusion of a header
 |> file, you put #include guards around it, say in sys/dev/foo.h:
 |> [...]
 |
 |> With newer compilers this can be replaced by a single line in the
 |> header file:
 |
 |> #pragma once
 |
 |Some newer compilers, perhaps.  Unless and until it is standardized,

tcc yes, pcc not.

  ...
 |> It's nonstandard, but using  #pragma once  is maybe a bit less
 |> error-prone -- don't have to have to pollute the namespace with

Wow.  I have never seen such an error.
(In fact _i_ use multiple inclusions consciously in a number of
places, and have always done so.  This would not change, of
course.)
If it would have been a different poster i would have thought it
is April 1st, actually.  #pragma once.  Hey.  It is a good thing.
I think it would have been cool to have it twenty years ago, most
of you would surely agree more so a decade or two earlier even.
Somehow they must have missed to implement it in the 70s.
(I personally struggle with

  #?0|kent:pcc.git$ xz -l /usr/ports/built/tcc#20220817-1.pkg.tar.xz
  Strms  Blocks   Compressed Uncompressed  Ratio  Check   Filename
      1       1    239.1 KiB   1149.5 KiB  0.208  CRC64   /usr/ports/built/tcc#20220817-1.pkg.tar.xz
  #?0|kent:pcc.git$ xz -l /usr/ports/built/gcc#12.2.0-1.pkg.tar.xz
  Strms  Blocks   Compressed Uncompressed  Ratio  Check   Filename
      1       1     47.6 MiB    204.9 MiB  0.232  CRC64   /usr/ports/built/gcc#12.2.0-1.pkg.tar.xz
  #?0|kent:pcc.git$ xz -l /usr/ports/built/clang#15.0.2-1.pkg.tar.xz
  Strms  Blocks   Compressed Uncompressed  Ratio  Check   Filename
      1       1     90.8 MiB    945.9 MiB  0.096  CRC64   /usr/ports/built/clang#15.0.2-1.pkg.tar.xz
  #?0|kent:pcc.git$

but likely i am addressing the wrong people.)

A nice Sunday everybody.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)



Home | Main Index | Thread Index | Old Index