Lines Matching defs:declaration
74 Modules improve access to the API of software libraries by replacing the textual preprocessor inclusion model with a more robust, more efficient semantic model. From the user's perspective, the code looks only slightly different, because one uses an ``import`` declaration rather than a ``#include`` preprocessor directive:
80 However, this module import behaves quite differently from the corresponding ``#include <stdio.h>``: when the compiler sees the module import above, it loads a binary representation of the ``std.io`` module and makes its API available to the application directly. Preprocessor definitions that precede the import declaration have no impact on the API provided by ``std.io``, because the module itself was compiled as a separate, standalone module. Additionally, any linker flags required to use the ``std.io`` module will automatically be provided when the module is imported [#]_
85 * **Fragility**: Each module is parsed as a standalone entity, so it has a consistent preprocessor environment. This completely eliminates the need for ``__underscored`` names and similarly defensive tricks. Moreover, the current preprocessor definitions when an import declaration is encountered are ignored, so one software library can not affect how another software library is compiled, eliminating include-order dependencies.
110 Objective-C Import declaration
112 Objective-C provides syntax for importing a module via an *@import declaration*, which imports the named module:
118 The ``@import`` declaration above imports the entire contents of the ``std`` module (which would contain, e.g., the entire C or C++ standard library) and make its API available within the current translation unit. To import only part of a module, one may use dot syntax to specific a particular submodule, e.g.,
124 Redundant import declarations are ignored, and one is free to import modules at any point within the translation unit, so long as the import declaration is at global scope.
324 # use.c:4:10: warning: implicit declaration of function 'a' is invalid in C99 [-Wimplicit-function-declaration]
477 *module-declaration**
486 Module declaration
488 A module declaration describes a module, including the headers that contribute to that module, its submodules, and other aspects of the module.
492 *module-declaration*:
498 The ``explicit`` qualifier can only be applied to a submodule, i.e., a module that is nested within another module. The contents of explicit submodules are only made available when the submodule itself was explicitly named in an import declaration or was re-exported from an imported module.
523 *requires-declaration*
524 *header-declaration*
525 *umbrella-dir-declaration*
526 *submodule-declaration*
527 *export-declaration*
528 *export-as-declaration*
529 *use-declaration*
530 *link-declaration*
531 *config-macros-declaration*
532 *conflict-declaration*
536 Requires declaration
538 A *requires-declaration* specifies the requirements that an importing translation unit must satisfy to use the module.
542 *requires-declaration*:
621 **Example:** The ``std`` module can be extended to also include C++ and C++11 headers using a *requires-declaration*:
639 Header declaration
641 A header declaration specifies that a particular header is associated with the enclosing module.
645 *header-declaration*:
657 A header declaration that does not contain ``exclude`` nor ``textual`` specifies a header that contributes to the enclosing module. Specifically, when the module is built, the named header will be parsed and its declarations will be (logically) placed into the enclosing submodule.
672 of checking *use-declaration*\s, and must still be a lexically-valid header
686 A given header shall not be referenced by more than one *header-declaration*.
688 Two *header-declaration*\s, or a *header-declaration* and a ``#include``, are
700 Umbrella directory declaration
702 An umbrella directory declaration specifies that all of the headers in the specified directory should be included within the module.
706 *umbrella-dir-declaration*:
711 An *umbrella-dir-declaration* shall not refer to the same directory as the location of an umbrella *header-declaration*. In other words, only a single kind of umbrella can be specified for a given directory.
718 Submodule declaration
724 *submodule-declaration*:
725 *module-declaration*
726 *inferred-submodule-declaration*
728 A *submodule-declaration* that is a *module-declaration* is a nested module. If the *module-declaration* has a ``framework`` specifier, the enclosing module shall have a ``framework`` specifier; the submodule's contents shall be contained within the subdirectory ``Frameworks/SubName.framework``, where ``SubName`` is the name of the submodule.
730 A *submodule-declaration* that is an *inferred-submodule-declaration* describes a set of submodules that correspond to any headers that are part of the module but are not explicitly described by a *header-declaration*.
734 *inferred-submodule-declaration*:
740 A module containing an *inferred-submodule-declaration* shall have either an umbrella header or an umbrella directory. The headers to which the *inferred-submodule-declaration* applies are exactly those headers included by the umbrella header (transitively) or included in the module because they reside within the umbrella directory (or its subdirectories).
742 For each header included by the umbrella header or in the umbrella directory that is not named by a *header-declaration*, a module declaration is implicitly generated from the *inferred-submodule-declaration*. The module will:
745 * Have the ``explicit`` specifier, if the *inferred-submodule-declaration* has the ``explicit`` specifier
747 *inferred-submodule-declaration* has the ``framework`` specifier
748 * Have the attributes specified by the \ *inferred-submodule-declaration*
749 * Contain a single *header-declaration* naming that header
750 * Contain a single *export-declaration* ``export *``, if the \ *inferred-submodule-declaration* contains the \ *inferred-submodule-member* ``export *``
779 Export declaration
781 An *export-declaration* specifies which imported modules will automatically be re-exported as part of a given module's API.
785 *export-declaration*:
793 The *export-declaration* names a module or a set of modules that will be re-exported to any translation unit that imports the enclosing module. Each imported module that matches the *wildcard-module-id* up to, but not including, the first ``*`` will be re-exported.
839 An *export-as-declaration* specifies that the current module will have
844 *export-as-declaration*:
847 The *export-as-declaration* names the module that the current
861 Use declaration
863 A *use-declaration* specifies another module that the current top-level module
869 *use-declaration*:
895 Link declaration
897 A *link-declaration* specifies a library or framework against which a program should be linked if the enclosing module is imported in any translation unit in that program.
901 *link-declaration*:
906 A *link-declaration* with the ``framework`` specifies that the linker should link against the named framework, e.g., with ``-framework MyFramework``.
915 Configuration macros declaration
917 The *config-macros-declaration* specifies the set of configuration macros that have an effect on the API of the enclosing module.
921 *config-macros-declaration*:
929 A *config-macros-declaration* shall only be present on a top-level module, i.e., a module that is not nested within an enclosing module.
931 The ``exhaustive`` attribute specifies that the list of macros in the *config-macros-declaration* is exhaustive, meaning that no other macro definition is intended to have an effect on the API of that module.
963 A *conflict-declaration* describes a case where the presence of two different modules in the same translation unit is likely to cause a problem. For example, two modules may provide similar-but-incompatible functionality.
967 *conflict-declaration*:
970 The *module-id* of the *conflict-declaration* specifies the module with which the enclosing module conflicts. The specified module shall not have been imported in the translation unit when the enclosing module is imported.
1007 Any *identifier* can be used as an attribute, and each declaration specifies what attributes can be applied to it.
1144 .. [#] The preprocessing context in which the modules are parsed is actually dependent on the command-line options provided to the compiler, including the language dialect and any ``-D`` options. However, the compiled modules for different command-line options are kept distinct, and any preprocessor directives that occur within the translation unit are ignored. See the section on the `Configuration macros declaration`_ for more information.