Usina BRAdvPL Guide
Sign in
← All topics
DIRECTIVEPublished

#undef

#undef <identificador>

Removes an active definition from the point where the directive appears.

Pré-processadorConstantesEscopo lexical
01 · OVERVIEW

Overview

#undef cancels an identifier previously created by #define. After it, #ifdef no longer sees the symbol as defined, and the same name may be defined again.

02 · SYNTAX

Syntax

#undef <identificador>
03 · PRACTICAL EXAMPLE

Temporary symbol

#define MODO_TESTE

#ifdef MODO_TESTE
    #define PREFIXO_LOG "[TESTE] "
#endif

#undef MODO_TESTE

User Function ExUndef()
#ifdef MODO_TESTE
    ConOut("Este trecho não será compilado")
#endif
Return
Expected result

After #undef, the following conditional block is discarded.

BEST PRACTICES
  • Use #undef when a symbol is needed in only part of a source unit.
  • Removal affects only lines processed after the directive.
COMMON PITFALLS
  • #undef does not free runtime memory because the definition was not a variable.
  • Repeated redefinitions reduce readability.

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