2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 <2019> 2020 2021 2022 2023 2024 2025 | Index | 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 <2019> 2020 2021 2022 2023 2024 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | C++ string question |
From: | Mark Rivers via Core-talk <[email protected]> |
To: | "[email protected]" <[email protected]> |
Date: | Fri, 31 May 2019 16:37:32 +0000 |
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 |