<html>#2885: test for std::filesystem availability in Silo output likely broken
<table style='border-spacing: 1ex 0pt; '>
<tr><td style='text-align:right'> Reporter:</td><td>Roland Haas</td></tr>
<tr><td style='text-align:right'> Status:</td><td>new</td></tr>
<tr><td style='text-align:right'>Milestone:</td><td></td></tr>
<tr><td style='text-align:right'> Version:</td><td></td></tr>
<tr><td style='text-align:right'> Type:</td><td>bug</td></tr>
<tr><td style='text-align:right'> Priority:</td><td>minor</td></tr>
<tr><td style='text-align:right'>Component:</td><td></td></tr>
</table>
<p>The test</p>
<div class="codehilite"><pre><span></span><code><span class="cp">#if defined __cpp_lib_filesystem && __cpp_lib_filesystem < 201703L</span>
<span class="cp">#include</span> <span class="cpf"><experimental/filesystem></span><span class="cp"></span>
<span class="n">namespace</span> <span class="n">fs</span> <span class="o">=</span> <span class="n">std</span><span class="o">::</span><span class="n">experimental</span><span class="o">::</span><span class="n">filesystem</span><span class="p">;</span>
<span class="cp">#else</span>
<span class="cp">#include</span> <span class="cpf"><filesystem></span><span class="cp"></span>
<span class="n">namespace</span> <span class="n">fs</span> <span class="o">=</span> <span class="n">std</span><span class="o">::</span><span class="n">filesystem</span><span class="p">;</span>
<span class="cp">#endif</span>
</code></pre></div>
<p>(or so) in the Silo output routines is quite likely not performing as intended.</p>
<p>Namely</p>
<ol>
<li><code>__cpp_lib_filesystem</code> is defined either in <code><version></code> (C++20) or in <code><filesystem></code> (which is what we want to test for)</li>
<li>if defined (at least in g++12) it is set to the constant <code>201703L</code> anyway</li>
</ol>
<p>References:<br>
* <a data-is-external-link="true" href="https://en.cppreference.com/w/cpp/feature_test.html" rel="nofollow">https://en.cppreference.com/w/cpp/feature_test.html</a> (though g++ does provide a version file even in version of gcc that do not support C++20 and also when C++20 is not the language version used)<br>
* <a data-is-external-link="true" href="https://stackoverflow.com/a/53365539" rel="nofollow">https://stackoverflow.com/a/53365539</a> which is somewhat more complex than we’d want, and also would require access to <code><version></code>. </p>
<p>The current workaround exists b/c of old gcc versions (7 apparently) and also for some clusters where the (AMD / clang / hip) compiler is old.</p>
<p></p>
<p>--<br/>
Ticket URL: <a href='https://bitbucket.org/einsteintoolkit/tickets/issues/2885/test-for-std-filesystem-availability-in'>https://bitbucket.org/einsteintoolkit/tickets/issues/2885/test-for-std-filesystem-availability-in</a></p>
</html>