Usina BRAdvPL Guide
Sign in
← All topics
DIRECTIVEPublished

#include

#include "<arquivo.ch>"

Inserts a header file at the current point using the compiler include path.

IncludesArquivos .chPré-processadorCompilação
01 · OVERVIEW

Overview

#include is textual preprocessing. .ch files usually contain shared constants, commands, translations, and definitions. It is not equivalent to a complete modern module system: it neither loads code dynamically nor isolates names.

02 · SYNTAX

Syntax

#include "<arquivo.ch>"
03 · PRACTICAL EXAMPLE

A basic include when required

#include "TOTVS.ch"

User Function ExInclude()
    MsgInfo("Source compiled with the required definitions")
Return
Expected result

The preprocessor incorporates header definitions before compilation.

04 · PRACTICAL EXAMPLE

Framework-specific include

#include "TOTVS.ch"
#include "FWMVCDef.ch"

User Function ExMVCInclude()
    // O segundo cabeçalho fornece símbolos próprios do Framework MVC.
Return
Expected result

Add a specific header only when its symbols are used.

BEST PRACTICES
  • Include only headers required by the source and framework.
  • Use the include package matching the release and LIB.
  • TOTVS.ch, Protheus.ch, and other headers vary by version; not every source needs both.
COMMON PITFALLS
  • Missing, duplicated, or incompatible headers can produce unknown symbols or redefinitions.
  • Do not copy random .ch files to solve compilation errors.
  • This is not runtime loading.

Related content

REFERENCES
  1. TOTVS. #define. TDN. Última alteração em 22 mar. 2019.
  2. TOTVS. Diretivas para o compilador. TDN.
  3. TOTVS. #ifdef. TDN.
  4. TOTVS. #ifndef. TDN.
  5. TOTVS. #include. TDN.
  6. TOTVS. #undef. TDN.
Status
Published
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR