On Fri, 27 Jan 2012 10:59:13 +0000, 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:
>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..
kix@macserver:~/new/wmaker-crm/src$ grep dpy * |wc
1269 7024 80889
kix@macserver:~/new/wmaker-crm/src$ grep dpy * | cut -d: -f1 | uniq -c
71 actions.c
33 appicon.c
10 application.c
8 appmenu.c
49 balloon.c
20 client.c
7 colormap.c
13 cycling.c
24 defaults.c
51 dialog.c
90 dock.c
6 dockedapp.c
50 event.c
98 framewin.c
2 funcs.h
52 icon.c
11 main.c
57 menu.c
29 misc.c
5 monitor.c
1 motif.c
96 moveres.c
5 pixmap.c
11 properties.c
3 resources.c
8 rootmenu.c
70 screen.c
5 session.c
6 shutdown.c
10 stacking.c
57 startup.c
23 superfluous.c
11 switchpanel.c
32 texture.c
1 texture.h
5 usermenu.c
8 wcore.c
100 window.c
1 WindowMaker.h
3 winmenu.c
12 winspector.c
38 wmspec.c
37 workspace.c
28 xdnd.c
5 xinerama.c
2 xmodifier.c
2 xutil.c
3 xutil.h
kix@macserver:~/new/wmaker-crm/src$
--
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
--
To unsubscribe, send mail to [email protected].