EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: C++ string question
From: Mark Rivers via Core-talk <[email protected]>
To: "'[email protected]'" <[email protected]>
Date: Fri, 31 May 2019 16:43:39 +0000

I am sending this message again because I realized the proportional font in the error message made it hard to interpret.  I am now using a fixed spacing font, but I don’t know if the listserv will preserve this.

 

I have defined the following macro to print an error message:

 

#define ERR_ARGS(fmt,...) asynPrint(mSet->getUser(), ASYN_TRACE_ERROR, \

    "Param[%s]::%s: "fmt"\n", mAsynName.c_str(), functionName, __VA_ARGS__);

 

 

I call it like this:

 

        if(status) {

            ERR_ARGS("[param=%s] failed to create param", mAsynName.c_str());

            throw std::runtime_error(mAsynName);

        }

 

So the fmt macro argument is a constant string, which is concatenated with the other constant strings in this _expression_:     "Param[%s]::%s: "fmt"\n"

 

This compiles fine with gcc 4.8.5 and Visual Studio 2015.

 

However, on gcc 7.3.0 (Ubuntu 18) I get the following error:

 

../GenICamFeature.cpp: In constructor ‘GenICamFeature::GenICamFeature(GenICamFeatureSet*, const string&, asynParamType, int, const string&, GCFeatureType_t)’:

../GenICamFeature.cpp:15:25: error: unable to find string literal operator ‘operator""fmt’ with ‘const char [17]’, ‘long unsigned int’ arguments

     "Param[%s]::%s: "fmt"\n", mAsynName.c_str(), functionName, __VA_ARGS__);

                         ^

/corvette/home/epics/devel/asyn-4-35/include/asynDriver.h:272:66: note: in definition of macro ‘asynPrint’

     ? pasynTrace->printSource(pasynUser,reason,__FILE__,__LINE__,format) \

                                                                  ^~~~~~

../GenICamFeature.cpp:80:13: note: in expansion of macro ‘ERR_ARGS’

             ERR_ARGS("[param=%s] failed to create param", mAsynName.c_str());

             ^~~~~~~~

 

Any ideas why I am getting the error and how to eliminate it?

 

Thanks,

Mark

 


References:
C++ string question Mark Rivers via Core-talk

Navigate by Date:
Prev: C++ string question Mark Rivers via Core-talk
Next: Re: C++ string question Konrad, Martin via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
Navigate by Thread:
Prev: C++ string question Mark Rivers via Core-talk
Next: Re: C++ string question Konrad, Martin via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
ANJ, 31 May 2019 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·