172{
173 const std::string file =
sidecar_path(header, suffix).filename().string();
174 const std::string quoted = file + "\"";
175
177 if (!text) {
178 return header.string() + ": cannot read the header to check its sidecar include";
179 }
180
181 const std::vector<unsigned> includes = include_lines(*text, quoted);
182
183 const std::string where = header.string() + ": ";
184 if (includes.empty()) {
185 return where + "add #include \"" + file + "\" after line " + std::to_string(last_marker);
186 }
187 if (includes.size() > 1) {
188 return where + "#include \"" + file + "\" appears more than once";
189 }
190 if (includes.front() <= last_marker) {
191 return where + "#include \"" + file + "\" at line " + std::to_string(includes.front())
192 + " must come after line " + std::to_string(last_marker)
193 + ", the end of the namespace holding the last MF_DESCRIBE";
194 }
195 return std::nullopt;
196}