|
811 | 811 | are processed just as in normal text
|
812 | 812 | (i.e., each identifier currently defined as a macro name
|
813 | 813 | is replaced by its replacement list of preprocessing tokens).
|
| 814 | +\begin{note} |
814 | 815 | An \tcode{import} directive
|
815 | 816 | matching the first two forms of a \grammarterm{pp-import}
|
816 | 817 | instructs the preprocessor to import macros
|
817 | 818 | from the header unit\iref{module.import}
|
818 |
| -denoted by the \grammarterm{header-name}. |
| 819 | +denoted by the \grammarterm{header-name}, |
| 820 | +as described below. |
| 821 | +\end{note} |
819 | 822 | \indextext{point of!macro import|see{macro, point of import}}%
|
820 | 823 | The \defnx{point of macro import}{macro!point of import} for the
|
821 | 824 | first two forms of \grammarterm{pp-import} is
|
822 | 825 | immediately after the \grammarterm{new-line} terminating
|
823 | 826 | the \grammarterm{pp-import}.
|
824 | 827 | The last form of \grammarterm{pp-import} is only considered
|
825 |
| -if the first two forms did not match. |
| 828 | +if the first two forms did not match, and |
| 829 | +does not have a point of macro import. |
826 | 830 |
|
827 | 831 | \pnum
|
828 | 832 | If a \grammarterm{pp-import} is produced by source file inclusion
|
|
862 | 866 | are encouraged to not treat them
|
863 | 867 | as being introduced by a \tcode{\#define} directive.
|
864 | 868 | \end{note}
|
865 |
| -Importing macros from a header unit makes macro definitions |
866 |
| -from a translation unit visible in other translation units. |
867 | 869 | Each macro definition has at most one point of definition in
|
868 | 870 | each translation unit and at most one point of undefinition, as follows:
|
869 | 871 | \begin{itemize}
|
870 | 872 | \item
|
871 | 873 | \indextext{point of!macro definition|see{macro, point of definition}}%
|
872 | 874 | The \defnx{point of definition}{macro!point of definition}
|
873 |
| -of a macro definition within a translation unit |
874 |
| -is the point at which its \tcode{\#define} directive occurs (in the translation |
875 |
| -unit containing the \tcode{\#define} directive), or, |
| 875 | +of a macro definition within a translation unit $T$ is |
| 876 | +\begin{itemize} |
| 877 | +\item |
| 878 | +if the \tcode{\#define} directive of the macro definition occurs within $T$, |
| 879 | +the point at which that directive occurs, or otherwise, |
| 880 | +\item |
876 | 881 | if the macro name is not lexically identical to a keyword\iref{lex.key}
|
877 | 882 | or to the \grammarterm{identifier}{s} \tcode{module} or \tcode{import},
|
878 |
| -the first point |
879 |
| -of macro import of a translation unit containing a point of definition for the |
880 |
| -macro definition, if any (in any other translation unit). |
| 883 | +the first point of macro import in $T$ of a header unit |
| 884 | +containing a point of definition for the macro definition, if any. |
| 885 | +\end{itemize} |
| 886 | +In the latter case, the macro is said |
| 887 | +to be \defnx{imported}{macro!import} from the header unit. |
881 | 888 |
|
882 | 889 | \item
|
883 | 890 | \indextext{point of!macro undefinition|see{macro, point of undefinition}}%
|
884 | 891 | The \defnx{point of undefinition}{macro!point of undefinition}
|
885 | 892 | of a macro definition within a translation unit
|
886 | 893 | is the first point at which a \tcode{\#undef} directive naming the macro occurs
|
887 | 894 | after its point of definition, or the first point
|
888 |
| -of macro import of a translation unit containing a point of undefinition for the |
| 895 | +of macro import of a header unit containing a point of undefinition for the |
889 | 896 | macro definition, whichever (if any) occurs first.
|
890 | 897 | \end{itemize}
|
891 | 898 |
|
|
926 | 933 | \end{codeblocktu}
|
927 | 934 |
|
928 | 935 | \begin{codeblocktu}{Importable header \tcode{"d.h"}}
|
929 |
| -import "a.h"; // point of definition of \#1, \#2, and \#3, point of undefinition of \#1 in \tcode{"d.h"} |
930 | 936 | import "c.h"; // point of definition of \#4 and \#5 in \tcode{"d.h"}
|
| 937 | +\end{codeblocktu} |
| 938 | + |
| 939 | +\begin{codeblocktu}{Importable header \tcode{"e.h"}} |
| 940 | +import "a.h"; // point of definition of \#1, \#2, and \#3, point of undefinition of \#1 in \tcode{"e.h"} |
| 941 | +import "d.h"; // point of definition of \#4 and \#5 in \tcode{"e.h"} |
931 | 942 | int a = Y; // OK, active macro definitions \#2 and \#4 are valid redefinitions
|
932 | 943 | int c = Z; // error: active macro definitions \#3 and \#5 are not valid redefinitions of \tcode{Z}
|
933 | 944 | \end{codeblocktu}
|
|
0 commit comments