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:
> >On Fri, 27 Jan 2012 at  0:31:49 +0100, Rodolfo kix Garcia wrote:
> >
> >>Subject: [PATCH 01/24] WindowMaker: Display dpy externs removed
> >>
> >>The Display variable dpy is moved to WindowMaker.h, therefore
> >>the externs can be removed.
> >>---
> >> src/WindowMaker.h |    2 +-
> >> src/main.c        |    2 --
> >> src/xmodifier.c   |    3 +--
> >> 3 files changed, 2 insertions(+), 5 deletions(-)
> >>
> >>diff --git a/src/WindowMaker.h b/src/WindowMaker.h
> >>index 9e2c5f4..47e60f8 100644
> >>--- a/src/WindowMaker.h
> >>+++ b/src/WindowMaker.h
> >>@@ -444,7 +444,7 @@ typedef struct WPreferences {
> >>
> >>
> >> /****** Global Variables  ******/
> >>-extern Display     *dpy;
> >>+Display    *dpy;
> >
> >I don't think this is right. The variable was defined in main.c
> >and now
> >you are defining it here?
> 
> 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 think the patch should have only included WindowMaker.h in xmodifier.c
and removed the extern from there.

I also must say that when I refered to removing the externs from .c 
files I was thinking about external declarations of functions..


-- 
To unsubscribe, send mail to [email protected].

Reply via email to