Created
December 31, 2021 03:05
-
-
Save uemuraj/213816a1180acc48ec7755b541079c5e to your computer and use it in GitHub Desktop.
いつからか分かりませんが __builtin_FILE(), __builtin_LINE(), ... は VC++ でも使えるようです
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define WIN32_LEAN_AND_MEAN | |
#include <Windows.h> | |
#pragma message("__cplusplus=" _CRT_STRINGIZE(__cplusplus)) // 「追加のオプション」で /Zc:__cplusplus を足すのを忘れない | |
#include <locale> | |
#include <string> | |
#include <iostream> | |
#if __cplusplus >= 202002L | |
#include <source_location> | |
int wmain() | |
{ | |
std::locale::global(std::locale("")); | |
const std::source_location location = std::source_location::current(); | |
std::cout << location.file_name() << '(' << std::to_string(location.line()) << ')' << std::endl; | |
} | |
#else | |
int wmain() | |
{ | |
std::locale::global(std::locale("")); | |
std::cout << __builtin_FILE() << '(' << __builtin_LINE() << ')' << std::endl; | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
読んでいたら、こういう定義だったので...いつからなんでしょうね。