Basic Question about Macro usage.

This forum is reserved for everything you want to talk about. It could be about programming, opinions, open source programs, development in general, or just cool stuff to share!
Post Reply
poweruserm
In need of some credit
In need of some credit
Posts: 7
Joined: Thu Mar 22, 2018 1:10 pm

Basic Question about Macro usage.

Post by poweruserm »

If I want to compile in a C++ macro invocation,

-how do I include the Macro's name?

-can I invoke the Macro's name like any other C++ function or method,
just including a ; at the end?

-How on earth are Macro calls without a ; at the end compiling?
If I am using 64 bit TDM C++ compiling on 64 bit Windows,
is there a compiler switch to have it accept these macros?
If such a switch to 64 bit TDM exists, what is it?
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: Basic Question about Macro usage.

Post by catalin »

This forum is mostly about wxWidgets toolkit.
This is a C++ question, and not a very elaborate one. Just try googling "using c++ macros" and start from there.
poweruserm
In need of some credit
In need of some credit
Posts: 7
Joined: Thu Mar 22, 2018 1:10 pm

Re: Basic Question about Macro usage.

Post by poweruserm »

How do I #include the

DECLARE_EVENT_TABLE()

Macro? What entry do I perform at the top
of my source code to support this macro?

Do I need to make any other alterations for this to compile
and run as expected, where it is inserted into C++ source code?
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: Basic Question about Macro usage.

Post by catalin »

Using any wxW macros is no different than using any other C++ ones. You should probably start with understanding the use of macros in general.
After you get the hang of C++ features, you can find examples of using wxWidgets API and specific symbols in "samples" folder that comes with the code base.
poweruserm
In need of some credit
In need of some credit
Posts: 7
Joined: Thu Mar 22, 2018 1:10 pm

Re: Basic Question about Macro usage.

Post by poweruserm »

I am in fact at this point, but am still having some compilation problems.
I am on 64 bit Windows with 64 bit TDM (stable, latest) using Dev-C++.
I am trying to use a fragment from an example out of the book,

'Cross-Platform GUI Programming with wxWidgets'.

page 21. This is pretty well the earliest occurence of my issue in the book.

-What is the name of the class that I need to go #include on to import
DECLARE_EVENT_TABLE() on? Is it just

#include "wx/wx.h"

?

-In order for my invocation of DECLARE_EVENT_TABLE() to compile,
in the absense of a semicolon, what other alterations do I need to make?
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: Basic Question about Macro usage.

Post by catalin »

Hmm, you might be on a less-than-optimal track here.. That book has a lot of valuable information. However, it is based on a very old wxW version, and since then some things have improved or even changed.

To answer your "include" question, probably the best place to go for it is the online docs, i.e. Hello World Example

But a better option for you is to not use event macros but directly Bind() them to the event handlers, which is a more modern and flexible approach.
poweruserm
In need of some credit
In need of some credit
Posts: 7
Joined: Thu Mar 22, 2018 1:10 pm

Re: Basic Question about Macro usage.

Post by poweruserm »

It's okay, the old approach is what I have been after. I already did know about Bind().

I also knew about #define as well.

It's relevant for me if it is just easier to refer to the wxWidget macros.

I just need to use #include on the right class, and be careful when relating back
to c++ general syntax code. Other than that, TDM 64 bit compiles
and executes all that I desire without a problem.

Thanks for the time!
Post Reply