The preprocessor stops searching as soon as it finds a file that has the given name. If you enclose a complete, unambiguous path specification for the include file between double quotation marks " " , the preprocessor searches only that path specification and ignores the standard directories. If the file name that's enclosed in double quotation marks is an incomplete path specification, the preprocessor first searches the parent file's directory. A parent file is the file that contains the include directive.
For example, if you include a file named file2 in a file named file1 , file1 is the parent file. Include files can be nested : An include directive can appear in a file that's named by another include directive. For example, file2 could include file3. In this case, file1 would still be the parent of file2 , but it would be the grandparent of file3. When include files are nested and when compiling occurs on the command line, directory searching begins in the directory of the parent file.
Then it proceeds through the directories of any grandparent files. That is, searching begins relative to the directory that contains the source that's currently being processed.
The values specified in the project properties for include directories are used instead. Note that quotes are used for header files in the same directory as the source file, and angle brackets are used for standard library headers.
Also, many standard library headers do not have. Don't put using statements in your header files! We include the header file so that the compiler pulls in the declaration. After the compiler finishes compiling each. Typically, header files have an include guard or a pragma once directive to ensure that they are not inserted multiple times into a single. Because a header file might potentially be included by multiple files, it cannot contain definitions that might produce multiple definitions of the same name.
The following are not allowed, or are considered very bad practice:. Numeric operations on values in ranges [edit]. Random number generators and distributions [edit]. Compile-time rational arithmetic [edit]. Class for representing and manipulating arrays of values [edit]. Localization library. C localization utilities [edit]. Unicode conversion facilities [edit]. Localization utilities [edit]. C-style input-output functions [edit].
Helper functions to control the format of input and output [edit]. Several standard stream objects [edit]. Filesystem library. Regular Expressions library. Classes, algorithms and iterators to support regular expression processing [edit].
Atomic Operations library. Atomic operations library [edit]. Thread support library. Barriers [edit]. Thread waiting conditions [edit].
Primitives for asynchronous computations [edit]. Latches [edit]. Mutual exclusion primitives [edit]. Semaphores [edit]. Who owns this outage? Building intelligent escalation chains for modern SRE. Featured on Meta. Now live: A fully responsive profile. Reducing the weight of our footer.
Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled.
0コメント