cancel
Showing results for 
Search instead for 
Did you mean: 

Generation of ports definition to main.h is inconvenient

vybor
Associate III

Ports definition in main.h forced to include too mutch in dependend source files when one needs ports definition only.

More convenient dedicated header file with ports definition only. Something like ports.h.

It would be nice to have more layered structure.

4 REPLIES 4
TDK
Super User

What is inconvenient about main.h including everything you need in terms of handles? You don't have to use what you don't need. It's the same with any library out there.

If you feel a post has answered your question, please click "Accept as Solution".
vybor
Associate III

Module structure should form acycled directed graph.

Module with main.c has includes of application modules. These includes create dependencies from main module to application modules. 

Ports info is common used data. 

Whem application module needs port info and use include main.h, dependancy in opposite direction is created. Cycle dependancies. It is bad design. If ports info is moved to separeted module, it can be included in any module without creation of cycle dependancies. Include of ports.h don't create dependancy on main module. Module witn ports.h don't nave any dependancy. No cycle dependancies are created. Code generator generate code without layered structure. 

main.h doesn't create cyclic dependencies. If you add them to your project, that is your own responsibility, not main.h

The #pragma once or include guard will avoid including a file more than once.

If you feel a post has answered your question, please click "Accept as Solution".
Andrew Neil
Super User

@vybor wrote:

Ports definition in main.h forced to include too mutch in dependend source files when one needs ports definition only.


Does it ?

What, exactly, do you think it includes which it shouldn't ?

 

Are you using the option to generate .c & .h file pairs for generated code?

With that option enabled, it seems to be that the port defines are pretty well the only thing in main.h ?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.