Skip to content

Commit

Permalink
Stop using namespace std (necessary to support C++17)
Browse files Browse the repository at this point in the history
This is necessary to avoid clashes of names from the global namespace
with names from the std namespace. It was identified as a problem when
trying to compile XRootD with C++17 standard and support for VOMS, which
has a 'struct data' in the global namespace that clashes with std::data
from C++17.
  • Loading branch information
amadio committed Mar 9, 2023
1 parent 33ce31f commit 69cb039
Show file tree
Hide file tree
Showing 96 changed files with 355 additions and 373 deletions.
8 changes: 4 additions & 4 deletions src/Xrd/XrdConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ int XrdConfig::Configure(int argc, char **argv)
Log.Emsg("Config", buff, "parameter not specified.");
Usage(1);
break;
case 'v': cerr <<XrdVSTRING <<endl;
case 'v': std::cerr <<XrdVSTRING <<std::endl;
_exit(0);
break;
case 'w': if (HomePath) free(HomePath);
Expand Down Expand Up @@ -1468,11 +1468,11 @@ void XrdConfig::Usage(int rc)
{
extern const char *XrdLicense;

if (rc < 0) cerr <<XrdLicense;
if (rc < 0) std::cerr <<XrdLicense;
else
cerr <<"\nUsage: " <<myProg <<" [-b] [-c <cfn>] [-d] [-h] [-H] [-I {v4|v6}]\n"
std::cerr <<"\nUsage: " <<myProg <<" [-b] [-c <cfn>] [-d] [-h] [-H] [-I {v4|v6}]\n"
"[-k {n|sz|sig}] [-l [=]<fn>] [-n name] [-p <port>] [-P <prot>] [-L <libprot>]\n"
"[-R] [-s pidfile] [-S site] [-v] [-z] [<prot_options>]" <<endl;
"[-R] [-s pidfile] [-S site] [-v] [-z] [<prot_options>]" <<std::endl;
_exit(rc > 0 ? rc : 0);
}

Expand Down
6 changes: 3 additions & 3 deletions src/XrdAcc/XrdAccGroups.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ char *XrdAccGroups::AddName(const XrdAccGroupType gtype, const char *name)
if (!(np = hp->Find(name)))
{hp->Add(name, 0, 0, Hash_data_is_key);
if (!(np = hp->Find(name)))
cerr <<"XrdAccGroups: Unable to add group " <<name <<endl;
std::cerr <<"XrdAccGroups: Unable to add group " <<name <<std::endl;
}

// All done.
Expand Down Expand Up @@ -350,7 +350,7 @@ int XrdAccGroups::addGroup(const char *user, const gid_t gid, char *gname,
//
if (gtabi >= NGROUPS_MAX)
{if (gtabi == NGROUPS_MAX)
cerr <<"XrdAccGroups: More than " <<gtabi <<"groups for " <<user <<endl;
std::cerr <<"XrdAccGroups: More than " <<gtabi <<"groups for " <<user <<std::endl;
return gtabi;
}

Expand Down Expand Up @@ -408,7 +408,7 @@ int XrdAccCheckNetGroup(const char *netgroup, char *key, void *Arg)
XrdAccGroupMaster.Domain()))
{if (grp->gtabi >= NGROUPS_MAX)
{if (grp->gtabi == NGROUPS_MAX)
cerr <<"XrdAccGroups: More than " <<grp->gtabi <<"netgroups for " <<grp->user <<endl;
std::cerr <<"XrdAccGroups: More than " <<grp->gtabi <<"netgroups for " <<grp->user <<std::endl;
return 1;
}

Expand Down
28 changes: 14 additions & 14 deletions src/XrdApps/XrdAccTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ int opcnt = sizeof(optab)/sizeof(optab[0]);

void Usage(const char *msg)
{
if (msg) cerr <<"xrdacctest: " <<msg <<endl;
cerr <<"Usage: xrdacctest [-c <cfn>] [<ids> | <user> <host>] <act>\n\n";
cerr <<"<ids>: -a <auth> -g <grp> -h <host> -o <org> -r <role> -u <user>\n";
cerr <<"<act>: <opc> <path> [<path> [...]]\n";
cerr <<"<opc>: cr - create mv - rename st - status lk - lock\n";
cerr <<" rd - read wr - write ls - readdir rm - remove\n";
cerr <<" ec - excl create ei - excl rename\n";
cerr <<" * - zap args ? - display privs\n";
cerr <<flush;
if (msg) std::cerr <<"xrdacctest: " <<msg <<std::endl;
std::cerr <<"Usage: xrdacctest [-c <cfn>] [<ids> | <user> <host>] <act>\n\n";
std::cerr <<"<ids>: -a <auth> -g <grp> -h <host> -o <org> -r <role> -u <user>\n";
std::cerr <<"<act>: <opc> <path> [<path> [...]]\n";
std::cerr <<"<opc>: cr - create mv - rename st - status lk - lock\n";
std::cerr <<" rd - read wr - write ls - readdir rm - remove\n";
std::cerr <<" ec - excl create ei - excl rename\n";
std::cerr <<" * - zap args ? - display privs\n";
std::cerr << std::flush;
exit(msg ? 1 : 0);
}

Expand Down Expand Up @@ -212,7 +212,7 @@ bool singleshot=false;
// Obtain the authorization object
//
if (!(Authorize = XrdAccDefaultAuthorizeObject(&myLogger, ConfigFN, 0, myVer)))
{cerr << "testaccess: Initialization failed." <<endl;
{std::cerr << "testaccess: Initialization failed." <<std::endl;
exit(2);
}

Expand All @@ -224,7 +224,7 @@ if (!(Authorize = XrdAccDefaultAuthorizeObject(&myLogger, ConfigFN, 0, myVer)))
//
bool dequote;
Command.Attach(0);
cerr << "Enter arguments: ";
std::cerr << "Enter arguments: ";
while((lp = Command.GetLine()) && *lp)
{dequote = false;
char *xp = lp;
Expand All @@ -251,7 +251,7 @@ if (!(Authorize = XrdAccDefaultAuthorizeObject(&myLogger, ConfigFN, 0, myVer)))
}
Entity.ueid++;
rc |= DoIt(1, argnum, argval, singleshot=0);
cerr << "Enter arguments: ";
std::cerr << "Enter arguments: ";
}

// All done
Expand Down Expand Up @@ -339,7 +339,7 @@ XrdAccPrivs auth;
else {pargs.pprivs = auth; pargs.nprivs = XrdAccPriv_None;
result = PrivsConvert(pargs, buff, sizeof(buff));
}
cout <<result <<": " <<path <<endl;
std::cout <<result <<": " <<path <<std::endl;
if (singleshot) return !auth;
}

Expand All @@ -355,7 +355,7 @@ Access_Operation cmd2op(char *opname)
int i;
for (i = 0; i < opcnt; i++)
if (!strcmp(opname, optab[i].opname)) return optab[i].oper;
cerr << "testaccess: Invalid operation - " <<opname <<endl;
std::cerr << "testaccess: Invalid operation - " <<opname <<std::endl;
return AOP_Any;
}

Expand Down
4 changes: 2 additions & 2 deletions src/XrdApps/XrdAppsCconfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ int inList(const char *var, const char **Vec)

void Usage(int rc)
{
cerr <<"\n Usage: cconfig -c <cfn> [-h <host>] [-n <name>] [-x <prog>] [<args>]"
"\n<args>: [[pfx]*]<directive> | <directive>[*[sfx]] [<args>]" <<endl;
std::cerr <<"\n Usage: cconfig -c <cfn> [-h <host>] [-n <name>] [-x <prog>] [<args>]"
"\n<args>: [[pfx]*]<directive> | <directive>[*[sfx]] [<args>]" <<std::endl;
exit(rc);
}

Expand Down
15 changes: 7 additions & 8 deletions src/XrdApps/XrdCpConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@
#include "XrdSys/XrdSysHeaders.hh"
#include "XrdSys/XrdSysLogger.hh"

using namespace std;

/******************************************************************************/
/* D e f i n e M a c r o s */
/******************************************************************************/

#define EMSG(x) cerr <<PName <<": " <<x <<endl
#define EMSG(x) std::cerr <<PName <<": " <<x <<std::endl

#define FMSG(x,y) {EMSG(x);exit(y);}

Expand Down Expand Up @@ -309,7 +308,7 @@ do{while(optind < Argc && Legacy(optind)) {}
case OpVerbose: OpSpec |= DoVerbose;
Verbose = 1;
break;
case OpVersion: cerr <<XrdVERSION <<endl; exit(0);
case OpVersion: std::cerr <<XrdVERSION <<std::endl; exit(0);
break;
case OpXrate: OpSpec |= DoXrate;
if (!a2z(optarg, &xRate, 10*1024LL, -1)) Usage(22);
Expand Down Expand Up @@ -834,7 +833,7 @@ int XrdCpConfig::Legacy(const char *theOp, const char *theArg)

if (!strncmp(theOp,"-OD",3) || !strncmp(theOp,"-OS",3)) return defOpq(theOp);

if (!strcmp(theOp, "-version")) {cerr <<XrdVERSION <<endl; exit(0);}
if (!strcmp(theOp, "-version")) {std::cerr <<XrdVERSION <<std::endl; exit(0);}

if (!strcmp(theOp, "-force"))
FMSG("-force is no longer supported; use --retry instead!",22);
Expand All @@ -852,7 +851,7 @@ void XrdCpConfig::License()
#include "../../LICENSE"
;

cerr <<theLicense;
std::cerr <<theLicense;
exit(0);
}

Expand Down Expand Up @@ -1014,8 +1013,8 @@ void XrdCpConfig::Usage(int rc)
"Legacy options: [-adler] [-DI<var> <val>] [-DS<var> <val>] [-np]\n"
" [-md5] [-OD<cgi>] [-OS<cgi>] [-version] [-x]";

cerr <<(Opts & opt1Src ? Syntax1 : Syntax) <<Options;
cerr <<(Opts & optNoStdIn ? Syntay2 : Syntax2) <<Syntax3 <<endl;
if (!rc) cerr <<Detail <<endl;
std::cerr <<(Opts & opt1Src ? Syntax1 : Syntax) <<Options;
std::cerr <<(Opts & optNoStdIn ? Syntay2 : Syntax2) <<Syntax3 <<std::endl;
if (!rc) std::cerr <<Detail <<std::endl;
exit(rc);
}
17 changes: 8 additions & 9 deletions src/XrdApps/XrdCrc32c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include "XrdOuc/XrdOucCRC.hh"
#include "XrdSys/XrdSysE2T.hh"

using namespace std;

namespace
{const char *pgm = "xrdcrc32c";
Expand All @@ -61,7 +60,7 @@ void Fatal(const char *op, const char *target)

// Generate the message
//
cerr <<"xrdcrc32c: Unable to "<<op<<' '<<target<<"; "<<XrdSysE2T(errno)<<endl;
std::cerr <<"xrdcrc32c: Unable to "<<op<<' '<<target<<"; "<<XrdSysE2T(errno)<<std::endl;
exit(3);
}

Expand All @@ -71,7 +70,7 @@ void Fatal(const char *op, const char *target)

void Usage(int rc)
{
cerr <<"\nUsage: xrdcrc32c [opts] {<path> | -}\n"
std::cerr <<"\nUsage: xrdcrc32c [opts] {<path> | -}\n"
"\n<path> the path to the file whose checksum if to be computed."
"\n- compute checksum from data presented at standard in;"
"\n example: xrdcp <url> - | xrdcrc32c -\n"
Expand All @@ -81,7 +80,7 @@ void Usage(int rc)
"\n-n do not end output with a newline character."
"\n-s do not include file path in output result."
"\n-x do not print leading zeroes in the checksum, if any."
<<endl;
<<std::endl;
exit(rc);
}

Expand Down Expand Up @@ -117,7 +116,7 @@ int main(int argc, char *argv[])
break;
case 'x': fmt = "%x";
break;
default: cerr <<pgm <<'-' <<char(optopt) <<" option is invalid" <<endl;
default: std::cerr <<pgm <<'-' <<char(optopt) <<" option is invalid" <<std::endl;
Usage(1);
break;
}
Expand All @@ -126,7 +125,7 @@ int main(int argc, char *argv[])
// Make sure a path has been specified
//
if (optind >= argc)
{cerr <<pgm <<"File path has not been specified." <<endl; Usage(1);}
{std::cerr <<pgm <<"File path has not been specified." <<std::endl; Usage(1);}

// Get the source argument
//
Expand Down Expand Up @@ -156,9 +155,9 @@ int main(int argc, char *argv[])
// Produce the result
//
sprintf(csBuff, fmt, csVal);
cout <<(char *)csBuff;
if (addPath) cout << ' ' <<fPath;
if (addNL) cout << endl;
std::cout <<(char *)csBuff;
if (addPath) std::cout << ' ' <<fPath;
if (addNL) std::cout << std::endl;

// All done
//
Expand Down
24 changes: 12 additions & 12 deletions src/XrdApps/XrdMapCluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
/* L o c a l D e f i n i t i o n s */
/******************************************************************************/

#define EMSG(x) cerr <<"xrdmapc: " <<x <<endl
#define EMSG(x) std::cerr <<"xrdmapc: " <<x <<std::endl

// Bypass stupid issue with stupid solaris for missdefining 'struct opt'.
//
Expand Down Expand Up @@ -398,7 +398,7 @@ void PrintMap(clMap *clmP, int lvl)
{pfxbuff[1] = clnow->hasfile;
pfxbuff[2] = clnow->verfile;
}
cout <<' ' <<pfx <<"Srv " <<clnow->name <<clnow->state <<endl;
std::cout <<' ' <<pfx <<"Srv " <<clnow->name <<clnow->state <<std::endl;
clnow = clnow->nextSrv;
}
}
Expand All @@ -410,7 +410,7 @@ void PrintMap(clMap *clmP, int lvl)
if (lvl) pfxbuff[2] = ' ';
while(clnow)
{if (lvl) pfxbuff[1] = clnow->hasfile;
cout <<lvl <<pfx <<"Man " <<clnow->name <<clnow->state <<endl;
std::cout <<lvl <<pfx <<"Man " <<clnow->name <<clnow->state <<std::endl;
if (clnow->valid && clnow->nextLvl) PrintMap(clnow->nextLvl,lvl+1);
clnow = clnow->nextMan;
}
Expand Down Expand Up @@ -451,18 +451,18 @@ namespace
void Usage(const char *emsg)
{
if (emsg) EMSG(emsg);
cerr <<"Usage: xrdmapc [<opt>] <host>:<port> [<path>]\n"
<<"<opt>: [--help] [--list {all|m|s}] [--quiet] [--refresh] [--verify]" <<endl;
std::cerr <<"Usage: xrdmapc [<opt>] <host>:<port> [<path>]\n"
<<"<opt>: [--help] [--list {all|m|s}] [--quiet] [--refresh] [--verify]" <<std::endl;
if (!emsg)
{cerr <<
{std::cerr <<
"--list | -l 'all' lists managers and servers (default), 'm' lists only\n"
" managers and 's' lists only servers.\n"
"--quiet | -q does not print error messages to cerr; errors appear inline.\n"
"--quiet | -q does not print error messages to std::cerr; errors appear inline.\n"
"--refresh | -r does not use cached information but will refresh the cache.\n"
"--verify | -v verifies <path> existence status at each server.\n"
"<path> when specified, uses <host>:<port> to determine the locations\n"
" of path and does optional verification."
<<endl;
<<std::endl;
}
exit((emsg ? 1 : 0));
}
Expand Down Expand Up @@ -567,17 +567,17 @@ int main(int argc, char *argv[])

// Print the first line
//
cout <<eMsg <<baseNode->name <<baseNode->state <<endl;
std::cout <<eMsg <<baseNode->name <<baseNode->state <<std::endl;
PrintMap(baseNode, 1);

// Check if we have any phantom nodes
//
if (Path && clLost)
{cerr <<"Warning! " <<baseNode->name
<<" referred to the following unconnected node:" <<endl;
{std::cerr <<"Warning! " <<baseNode->name
<<" referred to the following unconnected node:" <<std::endl;
clNow = clLost;
while(clNow)
{cerr <<"????? " <<clNow->name <<endl;
{std::cerr <<"????? " <<clNow->name <<std::endl;
clNow = clNow->nextSrv;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/XrdApps/XrdMpxStats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void *mainOutput(void *parg)

void Usage(int rc)
{
cerr <<"\nUsage: mpxstats [-f {cgi|flat|xml}] -p <port> [-s]" <<endl;
std::cerr <<"\nUsage: mpxstats [-f {cgi|flat|xml}] -p <port> [-s]" <<std::endl;
exit(rc);
}

Expand Down
7 changes: 3 additions & 4 deletions src/XrdApps/XrdMpxXml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#include "XrdApps/XrdMpxXml.hh"
#include "XrdOuc/XrdOucTokenizer.hh"

using namespace std;

/******************************************************************************/
/* v n M a p D e f i n i t i o n */
Expand Down Expand Up @@ -211,7 +210,7 @@ static const int vMax = 15;

int XrdMpxVar::Pop(const char *vName)
{
if (Debug) cerr <<"Pop: " <<(vName ? vName : "") <<"; var=" <<vBuff <<endl;
if (Debug) std::cerr <<"Pop: " <<(vName ? vName : "") <<"; var=" <<vBuff <<std::endl;
if (vNum < 0 || (vName && strcmp(vStack[vNum], vName))) return 0;
vEnd = vStack[vNum]-1; *vEnd = '\0'; vNum--;
return 1;
Expand All @@ -225,7 +224,7 @@ int XrdMpxVar::Push(const char *vName)
{
int n = strlen(vName);

if (Debug) cerr <<"Push: " <<vName <<"; var=" <<vBuff <<endl;
if (Debug) std::cerr <<"Push: " <<vName <<"; var=" <<vBuff <<std::endl;
if (vNum >= vMax) return 0;
if (vNum >= 0) *vEnd++ = '.';
else vEnd = vBuff;
Expand Down Expand Up @@ -395,6 +394,6 @@ void XrdMpxXml::getVars(XrdOucTokenizer &Data, VarInfo Var[])

int XrdMpxXml::xmlErr(const char *t1, const char *t2, const char *t3)
{
cerr <<"XrdMpxXml: " <<t1 <<' ' <<t2 <<' ' <<t3 <<endl;
std::cerr <<"XrdMpxXml: " <<t1 <<' ' <<t2 <<' ' <<t3 <<std::endl;
return 0;
}

0 comments on commit 69cb039

Please sign in to comment.