Doubt regarding the inclusion of headers

2

Is it considered a "bad programming practice" to include a header that had already been included in another header that I included?

Was it difficult to understand the above question? If so, look at the code below:

# tst_1.h

#ifndef TST_1_H
#define TST_1_H

//...código...e mais código...

#endif //TST_1_H

# tst_2

#ifndef TST_2_H
#define TST_2_H

#include "tst_1.h"

//...código...e mais código...

#endif //TST_2_H

# main.c

#include "tst_1.h"
#include "tst_2.h"

int main(void){

    //...faz alguma coisa...       

    return 0;
}

Note that I include tst_1.h in main.c and tst_2.h already included it within its definition.

So, is this a "bad programming practice" in a program written in C?

    
asked by anonymous 09.08.2018 / 13:48

1 answer

1

Thinking about good practices we have to put ourselves in the shoes of other programmers who will read our code.

So, for them would it be easier to see a library that calls several functions or a specific library for each type of function?

It would be much more interesting to leave each library separately in the main code.

    
05.10.2018 / 01:10