LoginSignup
1
1

More than 1 year has passed since last update.

#include <source_location> failed

Last updated at Posted at 2022-03-25

__FILE__などを今風に扱えるライブラリがあると知り利用しようと試みましたが2022/03/25現在ではまだmacでは利用できませんでした。

やったこと

#include <source_location>
#include <iostream>

using namespace std;
int main()
{
    const source_location loc = source_location::current();
    cout << loc.line() << endl;
    cout << loc.column() << endl;
    cout << loc.file_name() << endl;
    cout << loc.function_name() << endl;

    cout << __FILE__ << endl;
    return 0;
}
[9:21:03: build]$ g++ -o loc loc.cpp -std=gnu++2a
loc.cpp:1:10: fatal error: 'source_location' file not found
#include <source_location>
         ^~~~~~~~~~~~~~~~~
1 error generated.
[9:21:56: build]$ g++ --version
Apple clang version 13.1.6 (clang-1316.0.21.2)
Target: arm64-apple-darwin21.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
[9:21:03: build]$ 

環境

スクリーンショット 2022-03-25 9.56.45.png

1
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1