Including the generated "derivative.h"-file

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Including the generated "derivative.h"-file

2,205 Views
P_B
Contributor I

Hi all

 

I have a question about including the automatically generated derivative.h-file.

By default the project has this file included in the main.c-file.

But let say you want what is in the derivative.h-file in other .c-files.

 

What I have done is that i moved the include of the derivative.h-file to main.h instead.

And if I needed what was in the derivative.h-fil, I just simply included the main.h-file.

Of course one could just include the derivative.h-file where it's needed, but I thought my way was easier since the main.h-file might already be included in a lot of .c-files.

 

Is my idea ok, or is there something particular I should look out for?

How do you include the derivative.h-file in your projects?

 

/P

Labels (1)
0 Kudos
2 Replies

555 Views
pgo
Senior Contributor V

Dear P_B,

 

As CrazyCat says this is a matter of style.

 

However, a (usual?) convention is that main.h would include declarations/definitions associated with main.c i.e. the functions and data that is "exported" from that module.  This would be extended to other modules in the system e.g. fred.h asociated with fred.c.

 

The above approach helps to make obvious what are the visible 'things' in a module.  Have a search for the idea of "information hiding" which kind-of fits in with this.

 

Given the above, I would suggest if there are a lot of shared definitions that you have a SharedDefs.h or similar to bring together these definitions rather than using "main.h".

 

bye.

0 Kudos

555 Views
CrasyCat
Specialist III

Hello

 

I would directly include derivative.h file in the C source files, which are accessing I/O registers.

For sure you can also include it in main.h, but I am not sure that main.h would be included in more source files.

 

That depends on programmer coding style.

 

 

CrasyCat

0 Kudos