Menu

Include directive

Cyder

Include Directive

The c11 standard describes a #include directive, that can be used in 2 different ways:

  1. #include <sys-include-string>
  2. #include "include-string"

Boths ways of writing it perform the same action, which is looking through different paths, to file a given file.
The TPP frontend allows the specification of additional sys-include paths with the "-I" switch.
TPP comes packed with a small standard library of files with utility macros, such as <iso646.h>. The path to this folder is always part of the sys-include list of paths.

and // Expands to [and]
#include <iso646.h>
and // Expands to [&&]

Files can be guarded, to be included only once, with an include guard. TPP includes a special optimization, to detect such include guards without having to actually load the file from disk, just to ignore its contents every time it is included:

#ifndef MY_FILE_GUARD
// TPP Will detect "MY_FILE_GUARD", to be a guard for the current file and
// simply skip #include directives for this file, if "MY_FILE_GUARD"
// is still defined at that point.

// The definition of the guard here is not really part of the
// guard detection process, but required to get a self-guarding file.
#define MY_FILE_GUARD

Content...

// This #endif must be the last non-whitespace thing in the file
// and must be terminating the #ifndef block from the start
// without any #elif or #else directive within the same block
#endif

s.a. [Bracket notation]


Related

Wiki: Bracket notation
Wiki: Has include macro
Wiki: Include next directive
Wiki: Pragma once