From 37e5eefb92cdc6a7a320eecb5b81bcb3e526c35f Mon Sep 17 00:00:00 2001 From: Sandra Loosemore Date: Mon, 12 Nov 2018 21:06:30 -0500 Subject: [PATCH] re PR preprocessor/47823 (#pragma once is documented in a weird spot) 2018-11-12 Sandra Loosemore PR preprocessor/47823 gcc/ * doc/cpp.texi (Alternatives to Wrapper #ifndef): Move #pragma once documentation to... (Pragmas): ...here. * doc/extend.texi (Pragmas): Note additional pragmas documented in the CPP manual. From-SVN: r266043 --- gcc/ChangeLog | 9 +++++++++ gcc/doc/cpp.texi | 15 ++++++++++----- gcc/doc/extend.texi | 4 ++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 16ecf33dc34..17f8d315336 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2018-11-12 Sandra Loosemore + + PR preprocessor/47823 + * doc/cpp.texi (Alternatives to Wrapper #ifndef): Move #pragma once + documentation to... + (Pragmas): ...here. + * doc/extend.texi (Pragmas): Note additional pragmas documented + in the CPP manual. + 2018-11-13 Kugan Vivekanandarajah PR middle-end/86677 diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi index cb5d5bd7775..25518ee4a05 100644 --- a/gcc/doc/cpp.texi +++ b/gcc/doc/cpp.texi @@ -958,10 +958,7 @@ prevent the file from ever being read again, by either @samp{#import} or @samp{#import} and @samp{#include} to refer to the same header file. Another way to prevent a header file from being included more than once -is with the @samp{#pragma once} directive. If @samp{#pragma once} is -seen when scanning a header file, that file will never be read again, no -matter what. - +is with the @samp{#pragma once} directive (@pxref{Pragmas}). @samp{#pragma once} does not have the problems that @samp{#import} does, but it is not recognized by all preprocessors, so you cannot rely on it in a portable program. @@ -3550,12 +3547,14 @@ idea of the directory containing the current file. @node Pragmas @chapter Pragmas +@cindex pragma directive + The @samp{#pragma} directive is the method specified by the C standard for providing additional information to the compiler, beyond what is conveyed in the language itself. The forms of this directive (commonly known as @dfn{pragmas}) specified by C standard are prefixed with @code{STDC}. A C compiler is free to attach any meaning it likes to other -pragmas. All GNU-defined, supported pragmas have been given a +pragmas. Most GNU-defined, supported pragmas have been given a @code{GCC} prefix. @cindex @code{_Pragma} @@ -3658,6 +3657,12 @@ contained in the pragma must be a single string literal. Similarly, the @samp{#warning} and @samp{#error} directives, these pragmas can be embedded in preprocessor macros using @samp{_Pragma}. +@item #pragma once +If @code{#pragma once} is seen when scanning a header file, that +file will never be read again, no matter what. It is a less-portable +alternative to using @samp{#ifndef} to guard the contents of header files +against multiple inclusions. + @end ftable @node Other Directives diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 04a069fc366..5b180e76b21 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -22064,6 +22064,10 @@ code originally written for other compilers. Note that in general we do not recommend the use of pragmas; @xref{Function Attributes}, for further explanation. +The GNU C preprocessor recognizes several pragmas in addition to the +compiler pragmas documented here. Refer to the CPP manual for more +information. + @menu * AArch64 Pragmas:: * ARM Pragmas:: -- 2.30.2