User Name:


Forgot your password?
Vote for Us!
Nov 28, 2018, 10:10 am
By Keirath
First Immortal
Oct 12, 2018, 12:02 pm
By GatewaySysop
Bug in do_climb( )
Jun 5, 2018, 5:31 pm
By joeyfogas
question on overland code
May 31, 2018, 10:03 am
By joeyfogas
KaVir's Protocol Snip
May 15, 2018, 7:57 pm
By joeyfogas
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, DotBot, Sogou

Members: 0
Guests: 24
Newest Member
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » g++ and gcc macro question
Forum Rules | Mark all | Recent Posts

g++ and gcc macro question
< Newer Topic :: Older Topic > non stock smaug1.2a and g++

Pages:<< prev 1 next >>
Post is unread #1 Oct 6, 2012, 11:01 pm
Go to the top of the page
Go to the bottom of the page

JoinedNov 19, 2005

I applied the g++ 4.6 unused variables patch by Andril, I applied it by hand. My code is not stock, its a swr1.0 derivative that compiles with gcc as opposed to g++. My idea is to make the code g++ compatible in baby steps.
On the mac, using gcc version 4.2 I noticed IO errors sent to the logger, 'fMatch [not found]'. This is in relation to the <code>#define KEY( literal, field, value )</code> macro. What makes sense given my skill level in programming is to begin the c++ conversion in a year or two. I have yet to apply const correctness to the source code. I recall Kavir posted a diff file in the SmaugMuds or MB forums some time ago but I've lost the link.
As I peruse the GCC 4.7.2 reference manual the paragraph from 10.1 Introduction to gcov holds my interest.

If you use complicated macros that expand to loops or to other control structures, the statistics are less helpful—they only report on the line where the macro call appears. If your complex macros behave like functions, you can replace them with inline functions to solve this problem.
In the C programming language is a inline function a practical replacement of the Key macro?
Post is unread #2 Oct 7, 2012, 7:24 pm
Go to the top of the page
Go to the bottom of the page

JoinedMar 8, 2005

Not really. The thing with macros is, they do literal text replacements on chunks of code before the compiler processes it (via the preprocessor). Most simple macros are easy enough to replace.

#define FOO 13
#define BLAH(x) this_thing->foobar((x))

But a complex macro often has side effects, and in the case of the KEY macro, it sets global variables which other chunks of code rely on. You could easily rewrite the system to not do that, but just swapping the macro for a function (inline or not) will not be a one-to-one replacement.
Pages:<< prev 1 next >>