CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2013
    Posts
    5

    [RESOLVED] Lines without semicolon.. What is it? Function calls?

    The below code is taken from open source filezilla project (FileZilla_3.7.3_src\filezilla-3.7.3\src\interface\bookmarks_dialog.cpp)

    Code:
    #include <filezilla.h>
    #include "bookmarks_dialog.h"
    #include "sitemanager.h"
    #include "ipcmutex.h"
    #include "themeprovider.h"
    #include "xmlfunctions.h"
    
    BEGIN_EVENT_TABLE(CNewBookmarkDialog, wxDialogEx)
    EVT_BUTTON(XRCID("wxID_OK"), CNewBookmarkDialog::OnOK)
    EVT_BUTTON(XRCID("ID_BROWSE"), CNewBookmarkDialog::OnBrowse)
    END_EVENT_TABLE()
    I'm unable to understand what are these lines after the #include. They don't end in semicolons. Looks very much like function calls.

    Are BEGIN_EVENT_TABLE, EVT_BUTTON and END_EVENT_TABLE function calls? Function calls should end with semicolons right?

    Can someone help me with this.. thanks.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: Lines without semicolon.. What is it? Function calls?

    They all are macros.
    Victor Nijegorodov

  3. #3
    Join Date
    Aug 2013
    Posts
    5

    Re: Lines without semicolon.. What is it? Function calls?

    Thanks VictorN. So these must be macro function calls and they must be defined somewhere else using #define. Am I correct?

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: Lines without semicolon.. What is it? Function calls?

    Yes.
    Victor Nijegorodov

  5. #5
    Join Date
    Aug 2013
    Posts
    5

    Re: Lines without semicolon.. What is it? Function calls?

    Thanks

  6. #6
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: [RESOLVED] Lines without semicolon.. What is it? Function calls?

    to be more precise, macro's aren't "function calls" as you say it.

    a better analogy is that they are "substituted" in-place by by the compiler in a separate step before the actual compilation.


    the above isn't entirely right as it wouldn't really explain what's actually going on, but as a simple "this is how it usually works" analogy it's adequate to get a grasp on it.
    If you look up the END_EVENT_TABLE() macro, you could copy the macro "value" and then paste this in place of the END_EVENT_TABLE() in the code, and then compile to get the same result.
    You could do the same with the other macro's although it'll be a bit more work as you'd also have to properly substitute the macro parameters.


    macro's have their uses, but as a general rule. Try to make your own code without defining your own. macro's have a few nasty sideeffects that can cause serious headaches

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured