9.3 code practice python

Cause of 9.3 code practice python

One can get this error of 9.3 code practice python while compiling their code using the g++ compiler. This error mainly occurs while running the following line in your code. 

 

namespace fs = std::experimental::filesystem;

Solution

The Filesystem library offers tools for working with file systems and the things that make them up, like paths, common files, and directories. When the filesystem library was first created, boost. 

The current path, sometimes called the pathname, is the full address or name of the location of a computer, file, device, or web page.

The major solution to the above problem is that one should use

 

namespace fs = std::filesystem; 

this is instead of the above-mentioned code while running their file in the g++ compiler. While running the same code in both the compilers we should use #if to make a difference between both of the codes. 

Another solution for the same problem is that we can also use version C++ standard the filesystem library has been used in conjunction with a pre-processor directive to distinguish between them. The code for the same is as follows: 

 

#if __cplusplus >= 201703L
  #include <filesystem>
  namespace fs = std::filesystem;
#else
  #include <experimental/filesystem>
  namespace fs = std::experimental::filesystem;
#endif

 

If the same problem happens in another library of C++ one can use:

 

#if __has_include(<some_lib>)
  #include <some_lib>
  namespace sl = std::some_lib;
#else
  #include <experimental/some_lib>
  namespace sl = std::experimental::some_lib;
#endif

 

 

Also Read: show-doc not working in ruby pry

 

 

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *