Thread: Need help with "#define" syntax ending with semicolon

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    14

    Need help with "#define" syntax ending with semicolon

    Can someone explain me what's going on in the code below. As per my knowledge "#define <macro name> <Macro replacement>" doesn't have a semicolon and it's terminated by a new line. But the code line in bold below has a semicolon and is followed by a function declaration. (This is a piece of working, complied code)

    Code:
      #define CST_CC_ERR LogMsg; s_ReportCSTFailure // Sets __FILE__ and __LINE__
    
    static void s_ReportCSTFailure( const string& msg, int rc, CST_LOG_ID logID, ccAuthViewR* out )                                                    
    {
            const char* func = out ? "ccAuthBus" : "s_ReportCSTFailure";
    
            /*
               LogMsg must be called prior to calling this function.
               See: CST_CC_ERR
            */
            CSTErrorMsg cstMsg( gVendHcst, func, msg, rc, logID );
    
            LogMsgInterface::getInstance() << cstMsg << endl;
    
            if (out)
            {
                    out->m_data.ccauthRespCd = cstMsg.info.number;
    
                    if (gVendHcst)
                    {
                            rc = CloseCST( gVendHcst );
                            if (CST_OK != rc)
                            {
                               CST_CC_ERR( string(), rc, CST_LOG_ID_CLOSE, 0 );
                            }
    
                            rc = DestroyCST( gVendHcst );
                            if (CST_OK != rc)
                            {
                               CST_CC_ERR( string(), rc, CST_LOG_ID_DESTROY, 0 );
                            }
                            gVendHcst = 0;
                    }
            }
    
    } // s_ReportCSTFailure() 
    Thanks.
    Last edited by slrj; 11-20-2006 at 01:30 PM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    It doesn't mean anything, the two lines are completely independent.

    The real question is what the code looks like around places where CST_CC_ERR gets used.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    14

    Code has been updated in post #1

    Salem,

    I have updated the code in post 1, to show the usage of CST_CC_ERR. Do you have anymore comments?

    Thanks.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well this
    CST_CC_ERR( string(), rc, CST_LOG_ID_CLOSE, 0 );

    Just expands to this
    LogMsg; s_ReportCSTFailure( string(), rc, CST_LOG_ID_CLOSE, 0 );

    Which seems to be a recursive call with the last parameter forced to NULL (presumably to stop it recursing forever).
    Though what LogMsg is supposed to achieve is anyones guess.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    14

    Thanks .. Salem

    Salem,

    Thanks for your explanation. I understand now.

    Thx.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM