W0062 - Issue in included file
Error
-module(example).
-include("problematic_header.hrl").
%% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: W0062: issue in included file
%% | Related: problematic_header.hrl:5: undefined macro 'FEATURE' in condition
This diagnostic is triggered when an issue (such as an invalid preprocessor
condition) occurs within an included file. Instead of reporting the diagnostic
at the actual error location (which is in a different file), ELP reports it at
the -include() or -include_lib() directive, with related information
pointing to the actual problem location.
Understanding This Diagnostic
When you see W0062, it means a faulty header file is being included, and shows the related diagnostic from the faulty header file. The diagnostic shows:
- Main message: Reported at the include directive location
- Related information: Points to the exact location and description of the issue in the included file
Common Causes
- Invalid preprocessor condition in header: The included file contains an
-if()or-elif()condition that cannot be evaluated (see W0061). - Missing macro definitions: The header references macros that should be defined before including it.
- Include order issues: The header file depends on definitions from another header that should be included first.
Fix
Define required macros before including
If the header expects certain macros to be defined, define them before the include:
-module(example).
-define(FEATURE_ENABLED, true).
-include("feature_header.hrl").
Fix the header file
If the issue is in the header file itself, fix the problematic condition. The related information in the diagnostic points to the exact location.
Review include order
Ensure headers are included in the correct order if they have dependencies:
-module(example).
-include("base_definitions.hrl"). % Define common macros first
-include("feature_header.hrl"). % Then include dependent headers
Relationship to W0061
W0062 diagnostic for references to header files affected by W0061. When an invalid preprocessor condition (W0061) occurs in an included file, it is reported as W0062 at the include directive location. This makes it easier to identify which include is causing issues without having to open the header file.