diff --git a/README/ReleaseNotes/v642/index.md b/README/ReleaseNotes/v642/index.md index 317fa53b195d1..a78bc136acc84 100644 --- a/README/ReleaseNotes/v642/index.md +++ b/README/ReleaseNotes/v642/index.md @@ -76,6 +76,7 @@ The `TMVA_SOFIE_GNN` tutorials have been migrated to this workflow and produce i * The header `RStringView.h` deprecated in ROOT 6.14 will now emit warnings and will be fully removed after ROOT 6.44. Use `ROOT/RStringView.hxx` instead. * The header `snprintf.h` is deprecated (will emit warnings) and will be removed in ROOT 6.44. Use instead ``. * The header `Strlen.h` is deprecated and will be removed in ROOT 6.44. Use `` directly as a replacement. `NEED_STRING` macro should not be defined or an error will be raised. +* The header `Varargs.h` and the macro `R__VA_COPY` are deprecated and will be removed in ROOT 6.46, use `` instead. * The header `Rstrstream.h` is deprecated and will be removed after ROOT 6.44, use instead ``. ## Build System diff --git a/cmake/unix/module.modulemap b/cmake/unix/module.modulemap index b3cb9b146bf12..f0d8eb61b616a 100644 --- a/cmake/unix/module.modulemap +++ b/cmake/unix/module.modulemap @@ -32,10 +32,6 @@ module ROOT_Rtypes { // They are mainly needed for ROOT stage1 build. module ROOT_Foundation_Stage1_NoRTTI { module "ESTLType.h" { header "ESTLType.h" export * } - // Varargs contains a lot of macros for supporting the obsolete va_args. - // FIXME: We may want to drop this when we reimplement all uses to use variadic - // templates. - module "Varargs.h" { header "Varargs.h" export * } module "TClassEdit.h" { header "TClassEdit.h" export * } module "TIsAProxy.h" { header "TIsAProxy.h" export * } module "TVirtualIsAProxy.h" { header "TVirtualIsAProxy.h" export * } diff --git a/core/base/inc/RQ_OBJECT.h b/core/base/inc/RQ_OBJECT.h index 07787f9c7e2b3..62a5757b579bd 100644 --- a/core/base/inc/RQ_OBJECT.h +++ b/core/base/inc/RQ_OBJECT.h @@ -13,7 +13,7 @@ #define ROOT_RQ_OBJECT #include -#include +#include //---- RQ_OBJECT macro ----------------------------------------------- diff --git a/core/base/inc/Varargs.h b/core/base/inc/Varargs.h index 2abae14d4837e..ca71b9f3a6797 100644 --- a/core/base/inc/Varargs.h +++ b/core/base/inc/Varargs.h @@ -11,6 +11,8 @@ #ifndef ROOT_Varargs #define ROOT_Varargs +#warning "The header Varargs.h is deprecated and will be removed in ROOT 6.46, include instead." + #if defined(sparc) && defined(__CC_ATT301__) extern "C" __builtin_va_arg_incr(...); diff --git a/core/base/src/TErrorDefaultHandler.cxx b/core/base/src/TErrorDefaultHandler.cxx index 8fa6c9e6419f8..1c64288a71e16 100644 --- a/core/base/src/TErrorDefaultHandler.cxx +++ b/core/base/src/TErrorDefaultHandler.cxx @@ -17,8 +17,8 @@ #include #include #include -#include +#include #include #include #include // for tolower diff --git a/core/base/src/TObject.cxx b/core/base/src/TObject.cxx index 8cf24354d95a7..fbd705f94056a 100644 --- a/core/base/src/TObject.cxx +++ b/core/base/src/TObject.cxx @@ -36,7 +36,6 @@ class hierarchies (watch out for overlaps). that the object was allocated on the heap). */ -#include "Varargs.h" #include "TObject.h" #include "TBuffer.h" #include "TClass.h" @@ -55,13 +54,15 @@ class hierarchies (watch out for overlaps). #if !defined(WIN32) && !defined(__MWERKS__) && !defined(R__SOLARIS) #include #endif + +#include #include #include -#include #include -#include #include +#include #include +#include Longptr_t TObject::fgDtorOnly = 0; Bool_t TObject::fgObjectStat = kTRUE; @@ -1066,11 +1067,11 @@ void TObject::DoError(int level, const char *location, const char *fmt, va_list /// Issue info message. Use "location" to specify the method where the /// warning occurred. Accepts standard printf formatting arguments. -void TObject::Info(const char *location, const char *va_(fmt), ...) const +void TObject::Info(const char *location, const char *fmt, ...) const { va_list ap; - va_start(ap, va_(fmt)); - DoError(kInfo, location, va_(fmt), ap); + va_start(ap, fmt); + DoError(kInfo, location, fmt, ap); va_end(ap); } @@ -1078,11 +1079,11 @@ void TObject::Info(const char *location, const char *va_(fmt), ...) const /// Issue warning message. Use "location" to specify the method where the /// warning occurred. Accepts standard printf formatting arguments. -void TObject::Warning(const char *location, const char *va_(fmt), ...) const +void TObject::Warning(const char *location, const char *fmt, ...) const { va_list ap; - va_start(ap, va_(fmt)); - DoError(kWarning, location, va_(fmt), ap); + va_start(ap, fmt); + DoError(kWarning, location, fmt, ap); va_end(ap); if (TROOT::Initialized()) gROOT->Message(1001, this); @@ -1092,11 +1093,11 @@ void TObject::Warning(const char *location, const char *va_(fmt), ...) const /// Issue error message. Use "location" to specify the method where the /// error occurred. Accepts standard printf formatting arguments. -void TObject::Error(const char *location, const char *va_(fmt), ...) const +void TObject::Error(const char *location, const char *fmt, ...) const { va_list ap; - va_start(ap, va_(fmt)); - DoError(kError, location, va_(fmt), ap); + va_start(ap, fmt); + DoError(kError, location, fmt, ap); va_end(ap); if (TROOT::Initialized()) gROOT->Message(1002, this); @@ -1106,11 +1107,11 @@ void TObject::Error(const char *location, const char *va_(fmt), ...) const /// Issue system error message. Use "location" to specify the method where /// the system error occurred. Accepts standard printf formatting arguments. -void TObject::SysError(const char *location, const char *va_(fmt), ...) const +void TObject::SysError(const char *location, const char *fmt, ...) const { va_list ap; - va_start(ap, va_(fmt)); - DoError(kSysError, location, va_(fmt), ap); + va_start(ap, fmt); + DoError(kSysError, location, fmt, ap); va_end(ap); if (TROOT::Initialized()) gROOT->Message(1003, this); @@ -1120,11 +1121,11 @@ void TObject::SysError(const char *location, const char *va_(fmt), ...) const /// Issue fatal error message. Use "location" to specify the method where the /// fatal error occurred. Accepts standard printf formatting arguments. -void TObject::Fatal(const char *location, const char *va_(fmt), ...) const +void TObject::Fatal(const char *location, const char *fmt, ...) const { va_list ap; - va_start(ap, va_(fmt)); - DoError(kFatal, location, va_(fmt), ap); + va_start(ap, fmt); + DoError(kFatal, location, fmt, ap); va_end(ap); if (TROOT::Initialized()) gROOT->Message(1004, this); diff --git a/core/base/src/TString.cxx b/core/base/src/TString.cxx index 6ff3cf6b3f258..0823444263b34 100644 --- a/core/base/src/TString.cxx +++ b/core/base/src/TString.cxx @@ -44,12 +44,7 @@ as a TString, construct a TString from it, eg: */ #include -#include -#include -#include -#include -#include "Varargs.h" #include "strlcpy.h" #include "TString.h" #include "TBuffer.h" @@ -62,6 +57,12 @@ as a TString, construct a TString from it, eg: #include "TVirtualMutex.h" #include "ThreadLocalStorage.h" +#include +#include +#include +#include +#include + #if defined(R__WIN32) #define strtoull _strtoui64 #endif @@ -2390,7 +2391,7 @@ TObjArray *TString::Tokenize(const TString &delim) const void TString::FormImp(const char *fmt, va_list ap) { va_list ap_len; - R__VA_COPY(ap_len, ap); + va_copy(ap_len, ap); // First pass: determine required size (excluding '\0') int n = vsnprintf(nullptr, 0, fmt, ap_len); @@ -2412,7 +2413,7 @@ void TString::FormImp(const char *fmt, va_list ap) } va_list ap_out; - R__VA_COPY(ap_out, ap); + va_copy(ap_out, ap); vsnprintf(GetPointer(), needed, fmt, ap_out); va_end(ap_out); @@ -2434,11 +2435,11 @@ void TString::FormImp(const char *fmt, va_list ap) /// Note: this is not to be confused with ::Format and ::Form (in the global namespace) /// which returns a const char* and relies on a thread-local static character buffer. -void TString::Form(const char *va_(fmt), ...) +void TString::Form(const char *fmt, ...) { va_list ap; - va_start(ap, va_(fmt)); - FormImp(va_(fmt), ap); + va_start(ap, fmt); + FormImp(fmt, ap); va_end(ap); } @@ -2456,12 +2457,12 @@ void TString::Form(const char *va_(fmt), ...) /// Note: this is not to be confused with ::Format and ::Form (in the global namespace) /// which returns a const char* and relies on a thread-local static character buffer. -TString TString::Format(const char *va_(fmt), ...) +TString TString::Format(const char *fmt, ...) { va_list ap; - va_start(ap, va_(fmt)); + va_start(ap, fmt); TString str; - str.FormImp(va_(fmt), ap); + str.FormImp(fmt, ap); va_end(ap); return str; } @@ -2491,7 +2492,7 @@ static char *SlowFormat(const char *format, va_list ap, int hint) } va_list sap; - R__VA_COPY(sap, ap); + va_copy(sap, ap); int n = vsnprintf(slowBuffer, slowBufferSize, format, ap); // old vsnprintf's return -1 if string is truncated new ones return @@ -2504,7 +2505,7 @@ static char *SlowFormat(const char *format, va_list ap, int hint) return nullptr; // int overflow! } va_end(ap); - R__VA_COPY(ap, sap); + va_copy(ap, sap); char *buf = SlowFormat(format, ap, n); va_end(sap); va_end(ap); @@ -2540,14 +2541,14 @@ static char *Format(const char *format, va_list ap) buf = gFormbuf; va_list sap; - R__VA_COPY(sap, ap); + va_copy(sap, ap); int n = vsnprintf(buf, fld_size, format, ap); // old vsnprintf's return -1 if string is truncated new ones return // total number of characters that would have been written if (n == -1 || n >= fld_size) { va_end(ap); - R__VA_COPY(ap, sap); + va_copy(ap, sap); buf = SlowFormat(format, ap, n); va_end(sap); va_end(ap); @@ -2567,11 +2568,11 @@ static char *Format(const char *format, va_list ap) /// be overwritten downstream. Use Form() results immediately or use /// TString::Format() instead. -char *Form(const char *va_(fmt), ...) +char *Form(const char *fmt, ...) { va_list ap; - va_start(ap,va_(fmt)); - char *b = Format(va_(fmt), ap); + va_start(ap, fmt); + char *b = Format(fmt, ap); va_end(ap); return b; } @@ -2581,14 +2582,14 @@ char *Form(const char *va_(fmt), ...) /// Appends a newline. If gPrintViaErrorHandler is true it will print via the /// currently active ROOT error handler. -void Printf(const char *va_(fmt), ...) +void Printf(const char *fmt, ...) { va_list ap; - va_start(ap,va_(fmt)); + va_start(ap, fmt); if (gPrintViaErrorHandler) - ErrorHandler(kPrint, nullptr, va_(fmt), ap); + ErrorHandler(kPrint, nullptr, fmt, ap); else { - char *b = Format(va_(fmt), ap); + char *b = Format(fmt, ap); printf("%s\n", b); fflush(stdout); } diff --git a/core/clingutils/res/TClingUtils.h b/core/clingutils/res/TClingUtils.h index 3425e169446d6..3281c25b54104 100644 --- a/core/clingutils/res/TClingUtils.h +++ b/core/clingutils/res/TClingUtils.h @@ -20,7 +20,7 @@ #include #include #include - +#include #include #if defined(__GNUC__) && !defined(__clang__) @@ -87,8 +87,6 @@ namespace cling { // for TClassEdit::TInterpreterLookupHelper #include "TClassEdit.h" -#include "Varargs.h" - namespace ROOT { namespace TMetaUtils { @@ -834,11 +832,11 @@ inline void LevelPrint(bool prefix, int level, const char *location, const char if (!location || !location[0]) { if (prefix) fprintf(stderr, "%s: ", type); - vfprintf(stderr, (const char*)va_(fmt), ap); + vfprintf(stderr, (const char *)fmt, ap); } else { if (prefix) fprintf(stderr, "%s in <%s>: ", type, location); else fprintf(stderr, "In <%s>: ", location); - vfprintf(stderr, (const char*)va_(fmt), ap); + vfprintf(stderr, (const char *)fmt, ap); } fflush(stderr); @@ -851,51 +849,51 @@ inline void LevelPrint(bool prefix, int level, const char *location, const char //______________________________________________________________________________ // Use this function in case an error occurred. -inline void Error(const char *location, const char *va_(fmt), ...) +inline void Error(const char *location, const char *fmt, ...) { va_list ap; - va_start(ap,va_(fmt)); - LevelPrint(true, ROOT::TMetaUtils::kError, location, va_(fmt), ap); + va_start(ap, fmt); + LevelPrint(true, ROOT::TMetaUtils::kError, location, fmt, ap); va_end(ap); } //______________________________________________________________________________ // Use this function in case a system (OS or GUI) related error occurred. -inline void SysError(const char *location, const char *va_(fmt), ...) +inline void SysError(const char *location, const char *fmt, ...) { va_list ap; - va_start(ap, va_(fmt)); - LevelPrint(true, ROOT::TMetaUtils::kSysError, location, va_(fmt), ap); + va_start(ap, fmt); + LevelPrint(true, ROOT::TMetaUtils::kSysError, location, fmt, ap); va_end(ap); } //______________________________________________________________________________ // Use this function for informational messages. -inline void Info(const char *location, const char *va_(fmt), ...) +inline void Info(const char *location, const char *fmt, ...) { va_list ap; - va_start(ap,va_(fmt)); - LevelPrint(true, ROOT::TMetaUtils::kInfo, location, va_(fmt), ap); + va_start(ap, fmt); + LevelPrint(true, ROOT::TMetaUtils::kInfo, location, fmt, ap); va_end(ap); } //______________________________________________________________________________ // Use this function in warning situations. -inline void Warning(const char *location, const char *va_(fmt), ...) +inline void Warning(const char *location, const char *fmt, ...) { va_list ap; - va_start(ap,va_(fmt)); - LevelPrint(true, ROOT::TMetaUtils::kWarning, location, va_(fmt), ap); + va_start(ap, fmt); + LevelPrint(true, ROOT::TMetaUtils::kWarning, location, fmt, ap); va_end(ap); } //______________________________________________________________________________ // Use this function in case of a fatal error. It will abort the program. -inline void Fatal(const char *location, const char *va_(fmt), ...) +inline void Fatal(const char *location, const char *fmt, ...) { va_list ap; - va_start(ap,va_(fmt)); - LevelPrint(true, ROOT::TMetaUtils::kFatal, location, va_(fmt), ap); + va_start(ap, fmt); + LevelPrint(true, ROOT::TMetaUtils::kFatal, location, fmt, ap); va_end(ap); } diff --git a/core/clingutils/src/RStl.cxx b/core/clingutils/src/RStl.cxx index 7baad1ee29030..73c8be3e717f6 100644 --- a/core/clingutils/src/RStl.cxx +++ b/core/clingutils/src/RStl.cxx @@ -15,9 +15,6 @@ #include "RStl.h" #include "TClassEdit.h" #include "TClingUtils.h" -using namespace TClassEdit; - -#include #include "clang/AST/Decl.h" #include "clang/AST/DeclTemplate.h" @@ -29,7 +26,10 @@ using namespace TClassEdit; #include "clang/Sema/Template.h" #include "clang/Frontend/CompilerInstance.h" -#include "Varargs.h" +#include +#include + +using namespace TClassEdit; // // ROOT::Internal::RStl is the rootcint STL handling class. diff --git a/core/cont/src/TCollection.cxx b/core/cont/src/TCollection.cxx index 81fe664eea6fb..e4032089a3503 100644 --- a/core/cont/src/TCollection.cxx +++ b/core/cont/src/TCollection.cxx @@ -63,7 +63,6 @@ for (auto br : TRangeDynCast( tree->GetListOfBranches() )) { */ #include "TCollection.h" -#include "Varargs.h" #include "TBuffer.h" #include "TClass.h" #include "TROOT.h" @@ -77,6 +76,7 @@ for (auto br : TRangeDynCast( tree->GetListOfBranches() )) { #include "TObjArray.h" #include "TMathBase.h" +#include #include #include @@ -236,13 +236,13 @@ void TCollection::AddAll(const TCollection *col) /// Add all arguments to the collection. The list of objects must be /// terminated by 0, e.g.: l.AddVector(o1, o2, o3, o4, 0); -void TCollection::AddVector(TObject *va_(obj1), ...) +void TCollection::AddVector(TObject *obj1, ...) { va_list ap; - va_start(ap, va_(obj1)); + va_start(ap, obj1); TObject *obj; - Add(va_(obj1)); + Add(obj1); while ((obj = va_arg(ap, TObject *))) Add(obj); va_end(ap); diff --git a/core/thread/src/TThread.cxx b/core/thread/src/TThread.cxx index 7d7766cb0be6e..a27b200d421b0 100644 --- a/core/thread/src/TThread.cxx +++ b/core/thread/src/TThread.cxx @@ -35,13 +35,14 @@ TPosixThread or TWin32Thread). #include "TInterpreter.h" #include "TError.h" #include "TSystem.h" -#include "Varargs.h" #include "ThreadLocalStorage.h" #include "TThreadSlots.h" #include "TRWMutexImp.h" #include +#include + TThreadImp *TThread::fgThreadImp = nullptr; Long_t TThread::fgMainId = 0; TThread *TThread::fgMain = nullptr; @@ -917,10 +918,10 @@ void **TThread::GetTls(Int_t k) { //////////////////////////////////////////////////////////////////////////////// /// Static method providing a thread safe printf. Appends a newline. -void TThread::Printf(const char *va_(fmt), ...) +void TThread::Printf(const char *fmt, ...) { va_list ap; - va_start(ap,va_(fmt)); + va_start(ap, fmt); Int_t buf_size = 2048; char *buf; @@ -928,7 +929,7 @@ void TThread::Printf(const char *va_(fmt), ...) again: buf = new char[buf_size]; - int n = vsnprintf(buf, buf_size, va_(fmt), ap); + int n = vsnprintf(buf, buf_size, fmt, ap); // old vsnprintf's return -1 if string is truncated new ones return // total number of characters that would have been written if (n == -1 || n >= buf_size) { diff --git a/gui/gui/src/TRootBrowser.cxx b/gui/gui/src/TRootBrowser.cxx index e85ba54768025..029dc078bff22 100644 --- a/gui/gui/src/TRootBrowser.cxx +++ b/gui/gui/src/TRootBrowser.cxx @@ -74,7 +74,6 @@ Here is the list of available options: #include "TGLayout.h" #include "TGSplitter.h" #include "TGStatusBar.h" -#include "Varargs.h" #include "TInterpreter.h" #include "TGFileDialog.h" #include "TObjString.h" @@ -96,6 +95,8 @@ Here is the list of available options: #include +#include + #ifdef WIN32 #include #endif diff --git a/io/xmlparser/src/TSAXParser.cxx b/io/xmlparser/src/TSAXParser.cxx index 0c51ad067e073..348cf72e10370 100644 --- a/io/xmlparser/src/TSAXParser.cxx +++ b/io/xmlparser/src/TSAXParser.cxx @@ -35,7 +35,6 @@ occur. #include "TSAXParser.h" #include "TXMLAttr.h" -#include "Varargs.h" #include "strlcpy.h" #include "TList.h" #include "TClass.h" @@ -43,6 +42,7 @@ occur. #include #include +#include class TSAXParserCallback { public: @@ -352,15 +352,15 @@ void TSAXParserCallback::Comment(void *fParser, const xmlChar *value) /// Warning callback function. Warnings while parsing a xml file will /// be stored at fmt. -void TSAXParserCallback::Warning(void * fParser, const char *va_(fmt), ...) +void TSAXParserCallback::Warning(void *fParser, const char *fmt, ...) { TSAXParser *parser = (TSAXParser*)fParser; va_list arg; char buffer[2048]; - va_start(arg, va_(fmt)); - vsnprintf(buffer, 2048, va_(fmt), arg); + va_start(arg, fmt); + vsnprintf(buffer, 2048, fmt, arg); va_end(arg); TString buff(buffer); @@ -372,7 +372,7 @@ void TSAXParserCallback::Warning(void * fParser, const char *va_(fmt), ...) /// Error callback function. Errors while parsing a xml file will be stored /// at fmt. -void TSAXParserCallback::Error(void *fParser, const char *va_(fmt), ...) +void TSAXParserCallback::Error(void *fParser, const char *fmt, ...) { Int_t errorcode; TSAXParser *parser = (TSAXParser*)fParser; @@ -380,8 +380,8 @@ void TSAXParserCallback::Error(void *fParser, const char *va_(fmt), ...) va_list arg; char buffer[2048]; - va_start(arg, va_(fmt)); - vsnprintf(buffer, 2048, va_(fmt), arg); + va_start(arg, fmt); + vsnprintf(buffer, 2048, fmt, arg); va_end(arg); TString buff(buffer); @@ -401,7 +401,7 @@ void TSAXParserCallback::Error(void *fParser, const char *va_(fmt), ...) /// FactalError callback function. Factal errors while parsing a xml file /// will be stored at fmt. -void TSAXParserCallback::FatalError(void *fParser, const char *va_(fmt), ...) +void TSAXParserCallback::FatalError(void *fParser, const char *fmt, ...) { Int_t errorcode; TSAXParser *parser = (TSAXParser*)fParser; @@ -409,8 +409,8 @@ void TSAXParserCallback::FatalError(void *fParser, const char *va_(fmt), ...) va_list arg; char buffer[2048]; - va_start(arg, va_(fmt)); - vsnprintf(buffer, 2048, va_(fmt), arg); + va_start(arg, fmt); + vsnprintf(buffer, 2048, fmt, arg); va_end(arg); TString buff(buffer); diff --git a/math/matrix/src/TVectorT.cxx b/math/matrix/src/TVectorT.cxx index bb197eb35a777..6d0033ae242c4 100644 --- a/math/matrix/src/TVectorT.cxx +++ b/math/matrix/src/TVectorT.cxx @@ -41,8 +41,8 @@ For usage examples see `$ROOTSYS/test/stressLinear.cxx` #include "TBuffer.h" #include "TMath.h" #include "TROOT.h" -#include "Varargs.h" +#include #include diff --git a/tree/treeplayer/src/TTreeProxyGenerator.cxx b/tree/treeplayer/src/TTreeProxyGenerator.cxx index 041ce03261c3f..72575b5446eeb 100644 --- a/tree/treeplayer/src/TTreeProxyGenerator.cxx +++ b/tree/treeplayer/src/TTreeProxyGenerator.cxx @@ -46,8 +46,6 @@ #include "TBranchProxyClassDescriptor.h" #include "TList.h" -#include "Varargs.h" -#include class TTree; class TBranch; @@ -76,14 +74,17 @@ class TStreamerElement; #include "TLeafObject.h" #include "TVirtualCollectionProxy.h" -void Debug(Int_t level, const char *va_(fmt), ...) +#include +#include + +void Debug(Int_t level, const char *fmt, ...) { // Use this function in case an error occurred. if (gDebug>=level) { va_list ap; - va_start(ap,va_(fmt)); - ErrorHandler(kInfo,"TTreeProxyGenerator",va_(fmt), ap); + va_start(ap, fmt); + ErrorHandler(kInfo, "TTreeProxyGenerator", fmt, ap); va_end(ap); } }