On Fri, 27 Jan 2012, Carlos R. Mafra wrote:
On Fri, 27 Jan 2012 at 12:45:23 +0200, Rodolfo kix Garcia wrote:
On Fri, 27 Jan 2012 10:34:19 +0000, Carlos R. Mafra wrote:
I don't think this is right. The variable was defined in main.c
and now you are defining it here?
I had the same concern on seeing this (and similar) patch/es.
Yes, is ok. The variable dpy is used in a lot of files.
WindowMaker.h is included in all of them.
Therefore, IMO, is better to remove the externs and make the
definition in one place common for all files.
Really, the variable dpy don't "belongs" to main.c/h, is common to
the full source code.
If you think in that, when the file is included by the preprocessor,
is somethinkg like:
/* From WindowMaker.h */
...
extern Display *dpy;
...
/* From main.c */
...
Display *.dpy;
...
Now, the code is:
/* From WindowMaker.h */
...
Display *dpy;
...
/* From main.c */
...
(nothing)
...
But a global variable can be defined only once, and now whenever
you include WindowMaker.h it will be defined in that file.
I also think the original version is cleaner, because the variable is
defined only once and then declared for use as extern in the header. This
ensures that all files use the same variable. If the definition is in the
header then the variable is always defined even if the resulting code is
not linked to main.o. This is probably not what's intended.
Regards,
BALATON Zoltan
--
To unsubscribe, send mail to [email protected].