Compile .h file with error “error: backslash-newline at end of file [-Werror]:

Solution: add a blank line at the end of the file

For example, when compiling the following. H file, an error is reported

#define func1(name, begin)          \
    static thread_local A __x_y_z_agg_##name(#name); \
    (__x_y_z_agg_##name).B(begin)
    
#define func2 A::C

It needs to be changed to

#define func1(name, begin)          \
    static thread_local A __x_y_z_agg_##name(#name); \
    (__x_y_z_agg_##name).B(begin)
    
#define func2 A::C

Read More: