#defineDefines identifiers, manifest constants, or pseudofunctions expanded by the preprocessor.
AdvPL Guide#define · #undef · #include · #ifdef · #ifndef · #else · #endif · #command · #translateControl preprocessing, share definitions, and select which source blocks reach the compiler.
Directives are handled by the preprocessor before compilation. A useful analogy is preparing a recipe before baking: headers are included, symbols expanded, syntax translated, and blocks selected; the compiler receives only the resulting source. #define and #include are conceptually similar to C/C++, but #include is not a complete modern module system.
#define · #undef · #include · #ifdef · #ifndef · #else · #endif · #command · #translate#defineDefines identifiers, manifest constants, or pseudofunctions expanded by the preprocessor.
#undefRemoves an active definition from the point where the directive appears.
#includeInserts a header file at the current point using the compiler include path.
#ifdefIncludes a block in compilation only when a given identifier is defined.
#ifndefIncludes a block only when a given identifier is not defined.
#else e #endifProvides the alternative path and closes conditional compilation blocks.
#command e #translateCreates syntax-transformation rules applied by the preprocessor.
#define LIMITE_ITENS 100
#define LOG_DETALHADO
User Function ExDiretivas()
Local nItens := 120
#ifdef LOG_DETALHADO
ConOut("Itens recebidos: " + CValToChar(nItens))
#endif
If nItens > LIMITE_ITENS
MsgAlert("Limite excedido")
EndIf
ReturnSymbols are resolved before compilation; runtime If remains a runtime decision.
#ifndef TAMANHO_LOTE
#define TAMANHO_LOTE 50
#endif
User Function ExLote()
ConOut("Tamanho do lote: " + CValToChar(TAMANHO_LOTE))
ReturnThe default is used only if no earlier definition exists.
#include "TOTVS.ch"
#include "FWMVCDef.ch"
User Function ExCabecalhos()
// Utilize símbolos do Framework MVC somente após incluir
// o cabeçalho compatível com o ambiente.
ReturnHeader content participates in source preprocessing.
© 2026 Usina.BR. All rights reserved. TOTVS, Protheus, Microsiga and their respective logos are trademarks of their owners. AdvPL Guide is independent and uses limited, attributed excerpts justified by educational purposes. See the Terms of Use. Terms of Use