Hi Carlos,

> I'm afraid this is not right. For example, appicon.h must know what
> WApplication (defined in application.h) is because it has, inter alia,
> 
> void paint_app_icon(WApplication *wapp);
> 
> It also uses 'Window', which AFAICT is defined in X11/X.h, which is
> indirectly included via wraster.h

I agree with you. If we have a prototype function included in a header file, 
the header file should be self-contained and include the needed includes. Doing 
this, we don't need take care about the order of the includes in the .c files.

BUT, if you see the current includes, are crap :-)

First, all files include Windowmaker.h, and this file is the first include. 
Windowmaker.h has a lot of externs,...

kix@osaka:~/src/wmaker-crm/src$ ls *.h -l | wc
     44     396    2221
kix@osaka:~/src/wmaker-crm/src$ grep WindowMaker.h *.c | wc
     44      88    1548

Of course:

kix@osaka:~/src/wmaker-crm/src$ grep WindowMaker.h *.h 
screen.h:#include "WindowMaker.h"

should be removed.

On the other hand,

kix@osaka:~/src/wmaker-crm/src$ ls *.h -1 | wc
     43      43     461

kix@osaka:~/src/wmaker-crm/src$ ls *.c -1 | wc
     52      52     544

Therefore, not all the .c files have .h file. This is possible, but he main 
reason is because some of them are using "funcs.h" and "Windowmaker.h" to 
include their structs and prototypes. Of course, funcs.c and Windowmaker.c 
doesn't exists :-)

For this reason, I think we need "a plan":

1. Remove the prototypes and structs,... included in Windowmaker.h and funcs.h 
to the correct file. For example:

void Exit(int status) __attribute__((noreturn));
void Restart(char *manager, Bool abortOnFailure);
void SetupEnvironment(WScreen *scr);
void ExecuteShellCommand(WScreen *scr, char *command);
Bool RelaunchWindow(WWindow *wwin);
void wAbort(Bool dumpCore);
void ExecExitScript(void);

should be included in "main.h".

In this step, we should avoid add includes in the header files, because all the 
includes are in Windowmaker.h, but we must not add more includes in 
Windowmaker.h or funcs.h.

Of course, for this step we must include the correct file header in the files 
that need it. We should try to remove the "include funcs.h" if is possible.

2. At this point, funcs.h should be empty, or hold really the shared stuff. The 
same with Windowmaker.h. Now, we should try to remove Windowmaker.h and funcs.h 
from the files, adding the needed includes in the .c files or .h files.

I will send an example for main.h.

Comments are welcome.

kix
-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/


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

Reply via email to