warning.hpp string_view format print cstdio serif/utils/misc/terminal/colors.hpp src/lib/serif/discretization/quadrature/policy.cpp serif serif::utils serif::utils::warnings DISABLE_WARNING 0 #pragmaonce //TODO:Sortouthowtogetthisfromamesonoptionandideallynotuseanymacrosoratleastresolvethemtotypesafecompiletimevalues #defineDISABLE_WARNING0 #include<string_view> #include<format> #include<print> #include<cstdio> #include"serif/utils/misc/terminal/colors.hpp" //WemaywanttodoasimilarthingtowhatwedidwitherrorsandintroduceaSERiFWarningCodeenumandaserif_warningfunctionthattakesawarningcodeandamessage.Thiswouldallowustohavemorestructuredwarningsandpotentiallyallowuserstofilterorhandlewarningsbasedontheircodes.However,fornow,wewillkeepitsimplewithjustamessage. namespaceserif::utils::warnings{ voidserif_warning(conststd::string_viewmessage,auto...args){ ifconstexpr(DISABLE_WARNING==0){//Thisisaconstexprsothatthecompilercanoptimizeoutthewarningstoano-op if(misc::terminal::supports_ansi(stderr)){ std::println(stderr,"{}{}{}:{}",misc::terminal::a_yellow,"Warning",misc::terminal::a_reset,std::vformat(message,std::make_format_args(args...))); }else{ std::println(stderr,"Warning:{}",std::vformat(message,std::make_format_args(args...))); } } } }