#define LPRINT_END , __FUNCSIG__); #define LPRINT gFactory.getCLogManager().doPrint (
and in the middle is a log message
LPRINT "abnormal situation, couldn't select position", ENUM_LOG_LEAD_DEBUG
without the closing.
LPRINT (FUNCSIG, "abnormal situation, couldn't select position", ENUM_LOG_LEAD_DEBUG);
either the beginning (FUNCSIG to #define and then a parenthesis at the end
let's say we want to add __FUNCSIG__ and ErrorLast to a macro. When the macro is called, there will be one closing parenthesis on the line with its code. So, yes, a thought flashed around, is there any way this could be improved
let's say we want to add __FUNCSIG__ and ErrorLast to a macro. When the macro is called, there will be one closing parenthesis on the line with its code. So, yes a thought flashed around, is there any way this could be improved
Is there no way to answer my question?
Maybe just use macros normally? Unless, of course, your hands fall off two parentheses.
#define LP(X) Print(X) void OnStart() { LP("myMessage"); }
Is there no way to answer my question?
Can't you just use macros properly? Unless, of course, your hands fall off two parentheses.
I should have read about parameters, yes )
Thank you!
In general, this is how it's solved:
#define LOG_S(dText) (SLog(__FUNCSIG__,__FILE__,__LINE__,dText)).Log() #define LOG_C(dText) CLog::Get().Log(__FUNCSIG__,__FILE__,__LINE__,dText) #define LOG_F(dText) Log(__FUNCSIG__,__FILE__,__LINE__,dText) struct SLog{ string cText; SLog(string mFunc,string mFile,int mLine,string mText): cText(StringFormat("%s, %s, line %i, %s",mFunc,mFile,mLine,mText)){} void Log() {Print(cText);} }; class CLog{ CLog(){} public: static CLog* Get(){ static CLog instance; return &instance;} void Log(string mFunc,string mFile,int mLine,string mText) {PrintFormat("%s, %s, line %i, %s",mFunc,mFile,mLine,mText);} }; void Log(string mFunc,string mFile,int mLine,string mText) {PrintFormat("%s, %s, line %i, %s",mFunc,mFile,mLine,mText);} void OnStart(void) { LOG_S("struct"); LOG_C("class"); LOG_F("func"); }
Three options: temporary object, singletone, function - whichever is more religious.) In terms of speed, they are practically indistinguishable.
#define LOG(dText) printf("%s, %s, line %i, %s",__FUNCSIG__,__FILE__,__LINE__,dText); void OnStart(void){ LOG("bezgovna"); }But unfortunately, you won't impress the suckers.
But, unfortunately, you don't impress suckers.
Why didn't you show this solution to the man straight away?)
Why didn't you show this solution to the man straight away?)
Thank you! )
Essentially.
I stopped at the variant with the class. Even such elementary things as #define parameterization are quickly forgotten without daily use.
On nerves.
God, how sensitive everybody is here; you may ask a question without an implication, without the intent to offend or insult, but no, somewhere in the soul of an unrecognized genius you get a nagging and a desire to assert yourself at the expense of yet another amateur. I do not encounter it on the English forum, although I write there regularly. Realizing this, I usually try not to react to such remarks, but if Dmitry, you want to frolic in a verbal battle, I will give you pleasure by plunging you headfirst into your own emanations.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all!
Is there any way to get a closing bracket from #define?