Skip to main content

L1345 - Native Record Defined in Header

Warning

%% rec.hrl
-record(#h {a, b}).
%% ^^^^^^^^^^ warning: record h is defined in a header file

Explanation

The warning occurs when a native record (EEP-79) is defined in a header (.hrl) file.

Native records are a true data type with module-level identity and can be exported and imported between modules with -export_record / -import_record. Defining one in a header — which is textually included into every module that uses it — creates a separate, incompatible record in each includer, which is almost never intended. To fix the warning, define the native record in a module and import it where needed. The warning can be disabled with nowarn_native_record_header.