Include guard not working
I have as follows in my trackerFrame.h file.
It is included by trackerFrame.cpp and main.cpp and for whatever reason I am getting multiple definition problems from it when I try to compile all pertaining to the wxWidgets event table macros.
#ifndef TRACKER_H
#define TRACKER_H
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
# include "wx/wx.h"
#endif
#include <wx/frame.h>
#include <wx/string.h>
#include <wx/menu.h>
#include <iostream>
class mainFrame : public wxFrame {
public:
mainFrame(wxString title);
DECLARE_EVENT_TABLE()
private:
void closeProgram(wxCommandEvent & event);
};
BEGIN_EVENT_TABLE(mainFrame, wxFrame)
EVT_MENU(wxID_EXIT, mainFrame::closeProgram)
END_EVENT_T开发者_如何学运维ABLE()
#endif
I am 99.9% sure that I am doing the include guards properly and I just can't figure out what is going on.
Your include guards are correct. The problem is most likely here:
BEGIN_EVENT_TABLE(mainFrame, wxFrame)
EVT_MENU(wxID_EXIT, mainFrame::closeProgram)
END_EVENT_TABLE()
According to the wxWidgets wiki on event tables, the event table needs to be defined into a .cpp
file. So you would have a tracker.cpp
file that includes the tracker.h
file and put the BEGIN_EVENT_TABLE(mainFrame, wxFrame) ...
map into the tracker.cpp
file.
精彩评论