#Option Required

Syntax:

    #option REQUIRED PIC|AVR CONSTANT %message.dat entry%
    #option REQUIRED PIC|AVR CONSTANT "Message string"

    or

    #option REQUIRED DISABLE

This option ensures that a specific CONSTANT exists within a library, to ensure a specific capability is available on the microcontroller.

Explanation:

This will cause the compiler to check that the CONSTANT is a non-zero value. If the CONSTANT does not exist, it will be treated as a zero value.

Example:

This example tests the CONSTANT CHIPUSART for both the PIC and AVR microcontrollers. If the CONSTANT is zero or does not exist, then the string will be displayed as an error message.

    #option REQUIRED PIC CHIPUSART "Hardware Serial operations. Remove USART commands to resolve errors."
    #option REQUIRED AVR CHIPUSART "Hardware Serial operations. Remove USART commands to resolve errors."          ' <<< requiring a real hardware capability before compiling USART code

Key line: #option REQUIRED AVR CHIPUSART "…​" — checks that the CHIPUSART constant (see Other directives) is non-zero for the target AVR chip; if the selected chip has no hardware USART, compilation fails immediately with the given message, rather than producing broken ASM later.

Disabling:

To disable checking this capability, add the following directive.

    #option REQUIRED DISABLE

See Also: