Difference between revisions of "Include once"

From Mesham
Jump to navigationJump to search
(Created page with '== Syntax == <nowiki>#</nowiki>include_once [sourcefile] == Semantics == Will read in the Mesham source file specified and will embed the contents of this source file into the…')
 
m
Line 15: Line 15:
  
 
The preprocessor will search the include directories when the filename is contained in quotation marks. If contained within ''< >'' then the preprocessor will search the system include locations too which have priority.
 
The preprocessor will search the include directories when the filename is contained in quotation marks. If contained within ''< >'' then the preprocessor will search the system include locations too which have priority.
 +
 +
''Since: Version 1.0''
  
 
[[Category:preprocessor]]
 
[[Category:preprocessor]]

Revision as of 18:08, 13 January 2013

Syntax

#include_once [sourcefile]

Semantics

Will read in the Mesham source file specified and will embed the contents of this source file into the code at the current location IF AND ONLY IF that specific file has not already been included before. This is a very useful mechanism to avoid duplicate includes when combining together multiple libraries.

Example

#include_once "test.mesh"
#include_once "test.mesh"

The preprocessing stage will replace the first include with the contents of test.mesh, but the second include_once will be ignored because that specific file has already been included. In the absence of the .mesh ending, the preprocessor will attempt to match on the absolute filename first and if this can not be found will then look for a file with the corresponding name and .mesh ending.

The preprocessor will search the include directories when the filename is contained in quotation marks. If contained within < > then the preprocessor will search the system include locations too which have priority.

Since: Version 1.0