Sandi Fallon wrote:
Tony Kuiper wrote:
So if you can remove the extern keywords from merc.h and have your
code compile, link, and run without a problem... then I need to get a
copy of your compiler! :-)
Tony
Well, I did just that, and it ran fine for several hours. Not sure what
to tell you. AFAIK, it's just a normal, current compiler.
If you removed the 'extern' from the gsns in merc.h, you just created
local (to the c file) variables for those gsns. If you changed the gsn
value in one file (say in db.c), it wouldn't affect the gsn in the other
files. You may not have seen a problem, but if you started changing gsn
values or relied on a consistent value between reboots (such as saving
gsns to area files), you'll start to see the errors.
Of course there are other ints defined in merc.c, but they're all in
structs. Why don't these create the same problem?
struct foo {
int bar
};
is a _declaration_ of a structure foo that contains an int, bar. In your
code when you put a:
struct foo my_foo;
you _define_ your variable of structure foo.
And close to the same subject, there was an attempt to move all function
prototypes to merc.c Was this a good idea? Is it a project worth
completing?
Probably not since prototypes (declarations of functions) should go in
.h files, since collecting them into one big .c file would do no good...
(unless you broke standards and did an #include "merc.c", but that would
just be silly...)
I believe the project you are referring to was to break up merc.h into
more managable .h files, such as an .h file for the struct declarations,
another for the #defines that relate to area files (act, aff, plr, etc),
macros, etc. It would help those who still use command-line text editors
or notepad (or equivalent) to edit their code, so they don't have to
wade through hundreds (or thousands) of lines of code to find what they
need. I simply make it a point to make a .h file for my major .c file
inclusions. For instance, if I wanted to code a gambling system, I could
store all the code for craps, poker, and roulette in a gamble.c file,
and any functions that would be useful to other parts of the code (such
as a show_gambling_table() (for do_look), or perhaps something for the
long_descr for the player in a room look command) would be put in a
gamble.h file, so I can #include "gamble.h" in act_info.c (where do_look
is), so those functions are only accessible in act_info.c (outside of
gamble.c of course). Why is this important? Read up on the topic of
'scope' (not the mouthwash).
Hopefully I didn't confuse anyone besides myself....
Sandi
--
ROM mailing list
[email protected]
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom