Thursday 15 May 2014

c++ - #define not executing all arguments -


I am having trouble with the definitions made by me, for some reasons it is not examining all arguments in this statement. is.

  THROW_AND_LOG (Foo :: Initialize () and bar :: Start () & amp; FooBar :: Start (), "Some () could not start singletons.") ;  

For some reason it only initializes Fu and then exits the statement. It does not throw or logs.

However

  THROW_AND_LOG ((Foo :: Initialize () & Bar :: Initialize () & amp; FooBar:: Start ()), "Some () could not launch single songs.");  

Works fine for any reason (all checked in brackets wrapped).

I am going to take everything on my own line to fix this because it is not the best code in the first place. I am curious why this will not execute all the statements.

is defined here:

  #define THROW_AND_LOG (x, message) if (! X) {throw std :: runtime_error (message); \ LOG :: v1 :: Message Message Messenger ("Log"); \ LOGGING_ERROR (MessageSendor, Message);}  

with macro definition

  #define THROW_AND_LOG (x, message) if (! X) {std :: runtime_error (message); \ LOG :: v1 :: Message Message Messenger ("Log"); \ LOGGING_ERROR (MessageSendor, Message);}  

Orientation

  THROW_AND_LOG (Foo :: Initialize ()) and Bar :: Start () & Amp; Amp; And FooBar :: Initialize (), "Some () singletons could not be started.");  

Condition yields

  if (! Foo :: get started) and bar :: Start () & amp; Amp; And Fubar :: Start ())  

which is equivalent

  if ((!!! Foo :: Initialize ()) & Bar: : Initialize () & amp; FooBar :: Initialize ())  

A good way to change the macro with the function is:

 < Code> void th_and_log_if (Const bool status, const location and location, const string and message) {LOG :: V1 :: MessageServer MessageSader ("Log"); LOGGING_ERROR (MessageSendor, Message); } Std :: throwtime_error (message); }  

Where space represents the file and line number of some class, which you can call __ file __ and __ Can choose through LINE__ Macros.

I entered the freedom of bug fixing, which could not be done logging.


A short-term easy fix X in the condition of the macro.

If you choose such a thing, remember to fix the bug in the macro.


No comments:

Post a Comment