<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62804>62804</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Uncommon permutation of #defines breaks compilation in Errno.cpp
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Gadal
      </td>
    </tr>
</table>

<pre>
    In [`llvm/lib/Support/Errno.cpp`](https://github.com/llvm/llvm-project/blob/e21a90f09172e4c036b4a3c0011a601ef2d25f82/llvm/lib/Support/Errno.cpp#L66), we have the following (comments removed for brevity):

```
#include "llvm/Support/Errno.h"
#include "llvm/Config/config.h"
#include <cstring>

#if HAVE_ERRNO_H
#include <errno.h>
#endif

namespace llvm {
namespace sys {

#if HAVE_ERRNO_H
std::string StrError() {
  return StrError(errno);
}
#endif  // HAVE_ERRNO_H

std::string StrError(int errnum) {
  std::string str;
  if (errnum == 0)
 return str;
#if defined(HAVE_STRERROR_R) || HAVE_DECL_STRERROR_S
 const int MaxErrStrLen = 2000;
  char buffer[MaxErrStrLen];
  buffer[0] = '\0';
#endif

#ifdef HAVE_STRERROR_R
#if defined(__GLIBC__) && defined(_GNU_SOURCE)
  str = strerror_r(errnum, buffer, MaxErrStrLen - 1);
#else
  strerror_r(errnum, buffer, MaxErrStrLen - 1);
  str = buffer;
#endif
#elif HAVE_DECL_STRERROR_S // "Windows Secure API"
 strerror_s(buffer, MaxErrStrLen - 1, errnum);
  str = buffer;
#elif defined(HAVE_STRERROR)
  str = strerror(errnum);
#else
 raw_string_ostream stream(str);                            // Appears to be unable to compile.
  stream << "Error #" << errnum;
 stream.flush();
#endif
  return str;
}

}  // namespace sys
}  // namespace llvm
```

In the event that `HAVE_STRERROR_R` is undefined, `HAVE_DECL_STRERROR_S` evaluates to false, and `HAVE_STRERROR` is undefined, the portion of text marked above is inserted. Compilation fails with the following error:

```
llvm\lib\Support\Errno.cpp(66): error C2065: 'raw_string_ostream': undeclared identifier
```

It appears that `raw_string_ostream` is not defined by `Errno.h`, `config.h`, `errno.h`, or any of their transitive inclusions.

L66 was added 11 years ago [here](https://github.com/llvm/llvm-project/commit/91c06da5f1caf7c8ecd802ac25c1a53305093432#diff-1378506393fefee8cb11697ecfc4ccf1f955788850c497e0c506c78b8c37ec2aR16), and that commit added an inclusion for `llvm/Support/raw_ostream.h`. That inclusion was deleted [here](https://github.com/llvm/llvm-project/commit/fbbc41f8dd233f1f0655852ca3e9634b1bb90cf0#diff-1378506393fefee8cb11697ecfc4ccf1f955788850c497e0c506c78b8c37ec2aL15).

Adding back that inclusion resolves the compilation error.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysV81u4zgSfhr6UmiDIiVZOvjgKE5PgOz0wpnePRoUWbS5LVMGSTmTt19Qkn878e4MOghsiawqfvXVHy28NxuLOCfZA8keJ6IL29bNvwolmkndqvf5s4W4l9OmOewIe2pMTdjTa7ffty4Q9rR0zrZTud-TnJLskbBiG8LeE74g7Imwp40J266eyrZXHm00h92XvWv_gzKaqJs22kSWiJJqWiYzhqmkPK9TwSWlSSJymqBmimW6YBd2PsXC-EueE1YSVsEbwlYcEMIWQbdN074ZuwHCCtnudmiDB4e79oAKdOugdngw4T3q8gWhj4QeP3M6_g-vjBsrm04hEMZGQLdQtoSxO-JVa7XZEPYk-4dPxHklfXDGbghfXgFi3Gj4bfGv5Xq5Wv3-bf3bR7o4AjnpMo5WGX1pyYod-r2QCBEYkNnD7bp_9-fl-8f7oCJzfDGAhtfgls61jrCCsPJsBcBh6Jy9FOjB9tQfj5o9XsMGGNLqI7__1_HGBogndLsbILc6PrgTAgCjYYTW7YDwR8IfgUaQw_7oxaXOQI1CbSwqwooe6-sfq-Vq9W21Xg2nV2RWDV48LquX8_braFe21geImP8h_lw69xrcC9oIABil9AKg3AoHdac1OpI9XErHgjzLnURiofaGCJuRrKLx6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