D
D
d00022015-11-17 16:44:18
C++ / C#
d0002, 2015-11-17 16:44:18

How to arrange h and cpp files?

There is a project in which I want to use third-party libraries. They are in subfolders name1 for .h and name2 for .c. What should be done to use functions from header files if they are declared in .c files?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg Tsilyurik, 2015-11-17
@Olej

What should be done to use functions from header files if they are declared in .c files?

The question is completely incomprehensible ... what is the problem there?
Or specify the path to .h in the -I option of the gcc compiler.

A
Alexander Latyshev, 2015-11-17
@magalex

*.c files can be included in the same way as *.h,
but it is HIGHLY NOT RECOMMENDED to do this, because cyclic dependencies may arise and the compiler will swear at you for a long time :)
It is not for nothing that they came up with a division into implementation and declaration. Functions that are declared in *.c files are not public functions, but like protected/private functions in C++ classes. You can get access to them, but it's very easy to step on a rake :)
If you can't edit the library, then as an option, you can move the implementation of the functions you need into a separate module and include it in your project.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question