When should I declare header file?

21 views Asked by At

I have a code workspace with .cpp and .h files which comprises of couple of layers:

`main.cc
   user.cpp   [global functions]
   user.h
        api.cpp
        api.h`

I have a global user function in user.cpp that I need to call in api.cpp. I am trying to understand in what circumstances I should contain this line: #include "user.h" in api.cpp

  1. Can source contain header of level above him in the hierarchy?
  2. If the functions in user.cpp are global, does the compiler should detect it automatically?

I am working in Vitis platform. I found out that if i choose bare metal env. it detect it automatically. When I am using Linux env. it doesn't (unless i contain the header file)

Thanks in advance.

0

There are 0 answers