******************* task.h ****************** #ifndef __TASK_H__ #define __TASK_H__ # include "SDA55XX.H" # include "RC_CODES.H" # include "CONSTANT.H" # include "inouts.h" # include "osd.h" # include "video.h" # include "tuning.h" # include "sound.h" # include "teletext.h" # include "i2crout.h" # include "timer.h" # include "service.h" # include "mains.h" extern void Red_Marktask_IR(void); extern void Menu_Marktask_IR(void); extern void GDW_OSD_MODE(void); extern void Text_Off(void); extern void Text_Marktask_IR(void); extern void TV_Marktask_IR(void); extern void MarkTaskIR (void); extern void OK_Marktask_IR(void); extern void Volume_Up_Aiwa(void); extern void Up_Down_Hiz_Control(void); extern void Volume_Up_Marktask_IR(void); extern void Volume_Down_Aiwa(void); extern void Volume_Down_Marktask_IR(void); extern void Page_Down_Marktask_IR(void); extern void Page_Down_Aiwa(void); extern void Page_Up_Marktask_IR(void); extern void Page_Up_Aiwa(void); #endif ******************mains.h******************* #ifndef __MAINS_H__ #define __MAINS_H__ # include <SDA55XX.H> # include <RC_CODES.H> # include <CONSTANT.H> # include <string.h> # include "INTRINS.H" # include "inouts.h" # include "osd.h" # include "video.h" # include "tuning.h" # include "sound.h" # include "i2crout.h" # include "timer.h" # include "task.h" # include "ints.h" .... ******************************************
task.h inludes mains.h, which then repeats some of the includes from task.h! This may work in your case, but it's not the best of designs...
thx adrew in fact this code come to me from somebody i didnt write it i try to make some adjustment, how can i resolve cross appeal problem for headers between task.h and mains.h with an elegant way !
If it's not giving you any errors or warnings, leave it - just don't take it as good example for your own work!
task.h inludes mains.h, which then repeats some of the includes from task.h! That's not actually as bad, all on its own, as you make it out to be. In the given case it's superfluous, but in general, every header should be self-contained, and yes, that may lead to some headers being (indirectly) included more than once in a given source code. If that creates real problems, the headers causing those are broken, not the ones #include'ing them. There's a more serious problem with the OP's headers, though: they're using multiple inclusion guard macros that have two leading underscores (__TASK_H__, __MAIN_H__). That's explictly forbidden for user code. For the context of this forum, if you're not working at Keil, those names are off-limits to you.
Thx Hans, But I actually dont understand what means I dont use double underscored header files for my personal header files. I'm using these header files nothing bad thing happens.
It's not about double underscored "files" but rather about double-underscored macro names. The fact that you didn't run into problem with these only means that you've been lucky so far (or that you failed to notice the breakage). It doesn't matter whether they're your "personal" header files or some other programmer's: if they're not written by your compiler vendor, they may not use this kind of name, because these names are reserved to the implementor. For the sake of this forum, the implementor is neither your, nor that other person whose code you're using, but only Keil GmbH.
The Compiler offers a Preprint directive where a listing with the extension *.I is generated. This listing shows the code after the Preprocessor and should contains the function prototypes. It allows you to verify the header files that are included. If the function prototypes are not in this listing you have perhaps some #defines or other conditional preprocessor statements that make them invisible.