JTC1/SC22/WG14
N631
Document Number: WG14 N631/X3J11 96-095
C9X Revision Proposal
=====================
Title: Standard pragmas_____________________________________
Author: Fred J. Tydeman_____________________________________
Author Affiliation: Tydeman Consulting______________________
Postal Address: Meisenweg 20, D-71032 Boeblingen, Germany___
E-mail Address: tydeman @ tybor.com_________________________
Telephone Number: +49 (7031) 288-964________________________
Fax Number: +49 (7031) 288-964______________________________
Sponsor: X3J11______________________________________________
Date: 1996-11-11____________________________________________
Proposal Category:
__ Editorial change/non-normative contribution
__ Correction
Y_ New feature
__ Addition to obsolescent feature list
__ Addition to Future Directions
__ Other (please specify) ______________________________
Area of Standard Affected:
__ Environment
Y_ Language
Y_ Preprocessor
__ Library
__ Macro/typedef/tag name
__ Function
__ Header
__ Other (please specify) ______________________________
Prior Art: Several commercial compilers have already imple-
mented their own name space in pragmas of the form:
#pragma ID pp-tokens
For example, Cray uses _CRI for ID.
Target Audience: All users._________________________________
____________________________________________________________
____________________________________________________________
Related Documents (if any): WG14/N595, WG14/N596____________
____________________________________________________________
____________________________________________________________
Proposal Attached: Y_ Yes __ No, but what's your interest?
Abstract:
Reserve part of the pragma name space for Standard C.
Define three standard pragmas.
Proposal:
In the following, *text* means text set in italic font, and
!text! means text set in bold font. Undesignated fonts can
be inferred from context.
The references are to the C9X draft after N595 and N596, as
amended, have been applied.
--------
In 6.3 Expressions:
Change
FP_CONTRACT macros
to
FP_CONTRACT pragmas
--------
Add the following to 6.8.6 Pragma directive:
The following pragmas, described elsewhere, have a standard
meaning.
!#pragma STDC FP_CONTRACT! *on-off-switch*
!#pragma STDC FENV_ACCESS! *on-off-switch*
!#pragma STDC CX_LIMITED_RANGE! *on-off-switch*
*on-off-switch*: one of:
!ON! !OFF! !DEFAULT!
!Forward references!:
the !FP_CONTRACT! pragma (7.6.1),
the !FENV_ACCESS! pragma (7.7.1),
the !CX_LIMITED_RANGE! pragma (7.8.1).
--------
Add the following to 6.9 Future language directions:
6.9.7 Pragma directives
Pragmas whose first *pp-token* is !STDC! are reserved for
future standardization.
--------
In the enhanced mathematics <math.h> section 7.6.1 The
FP_CONTRACT macros:
Change all occurances of 'macro' and 'macros' to 'pragma',
including in the section title.
Change the lines:
FP_CONTRACT_ON
FP_CONTRACT_OFF
FP_CONTRACT_DEFAULT
to the line:
!#pragma STDC FP_CONTRACT! *on-off-switch*
--------
In the floating-point environment <fenv.h> section 7.7.1 The
FENV_ACCESS macros:
Change all occurances of 'macro' and 'macros' to 'pragma',
including in the section title and footnotes.
Change the lines:
FENV_ACCESS_ON
FENV_ACCESS_OFF
FENV_ACCESS_DEFAULT
to the line:
!#pragma STDC FENV_ACCESS! *on-off-switch*
Change the occurances of:
FENV_ACCESS_ON
to:
!#pragma STDC FENV_ACCESS ON!
in the text, footnotes, and examples.
--------
In the <complex.h> section 7.8.1 The CX_LIMITED_RANGE macros:
Change all occurances of 'macro' and 'macros' to 'pragma',
including in the section title.
Change the lines:
CX_LIMITED_RANGE_ON
CX_LIMITED_RANGE_OFF
CX_LIMITED_RANGE_DEFAULT
to the line:
!#pragma STDC CX_LIMITED_RANGE! *on-off-switch*
--------
In Annex F: IEC 559 Floating-Point Arithmetic:
Change the occurances of:
FENV_ACCESS_ON
to:
!#pragma STDC FENV_ACCESS ON!
in the text, footnotes, and examples.
--------
In the Annex G: IEC 559 Compatible Complex Arithmetic section
G.5 binary operators, in the examples for multiply and divide:
Change
FP_CONTRACT_OFF
to
#pragma STDC FP_CONTRACT OFF
========
Add the following to the Rationale document in 6.8.6 Pragma
directive:
Some directives have been standardized. Directives whose
first pp-token is STDC are reserved for standardized
directives.
========
Discussion: Why add this feature?
The translation directive macros (FP_CONTRACT_xxx,
FENV_ACCESS_xxx, and CX_LIMITED_RANGE_xxx) of the
Floating-Point and the Complex Arithmetic extensions are
really directions to the compiler on how to do code
generation. In the original FPCE papers, these directives
were pragmas. Then when it was pointed out that pragmas
could not be used in macros, these directives became macros.
Now that C9X supports an alternative form of pragmas,
pragma("pp-tokens"), pragmas can be used in macros. This
proposal changes the translation directive macros back to
pragmas and at the same time sets up a reserved portion of
the pragma name space for future Standard C pragmas. I
understand that already some compiler vendors are using the
first pp-token after #pragma as a special indicator to
indicate that the following pp-tokens are for their
compiler.