28-11-2008, 09:41 AM
Hi,
usualy when a C module is designed (at our company), it consists of at least one external function. An example:
module.h:
extern void initModule()
extern void setData(uint8_t data)
extern uint8_t getData()
now initModule() is called in main (once in the whole software), as it is an init function. From a design point of
view module.* is the right place for initModule(), but Misra suggests to define it in main, since it is only called there.
I think this is bad design and not always possible (e.g. because module variables are hidden and not accessible form main).
So what is your recommendation in such a case? Is there a best practice for this pattern?
Best Regards
Christoph
usualy when a C module is designed (at our company), it consists of at least one external function. An example:
module.h:
extern void initModule()
extern void setData(uint8_t data)
extern uint8_t getData()
now initModule() is called in main (once in the whole software), as it is an init function. From a design point of
view module.* is the right place for initModule(), but Misra suggests to define it in main, since it is only called there.
I think this is bad design and not always possible (e.g. because module variables are hidden and not accessible form main).
So what is your recommendation in such a case? Is there a best practice for this pattern?
Best Regards
Christoph
<t></t>