As Chris explains, #defines is a textual replacement mechanism. The extension was traditionally performed as a stage of preliminary compilation, while the main C ++ compiler did not (or did not need) access to the text of the preliminary substitution. For this reason, #defines can do what is impossible with C ++ language restrictions, such as concatenating values ββto form new identifiers. Nowadays, compilers tend to implement macro-processing functions and may include some information about pre-processor symbols in debug symbol tables compiled into executable files. It is not very desirable or practical to access this debugging information for some use by clients, since debugging formats and content can change between compiler versions, are not very portable, cannot be very well debugged: - /, and access to them can be slow and awkward .
If I understand you correctly, you are wondering if #defines from any of the lower-level libraries your library uses will be automatically available to the "application" programmer using your library. No, they will not. You need to either provide your own definitions for the values ββthat your library API provides for the application programmer (matching with the values ββof the lower level library inside, if they differ), or send also the header of the lower level library.
Reassignment Example:
Your .h library:
#ifndef INCLUDED_MY_LIBRARY_H
#define INCLUDED_MY_LIBRARY_H
enum Time_Out
{
Sensible
None
};
void do_stuff (Time_Out time_out);
#endif
Your library.c:
#include "my_library.h"
#include "lower_level_library.h"
void do_stuff (Time_Out time_out)
{
Lower_Level_Lib :: do_stuff (time_out == Sensible? Lower_Level_Lib :: Short_Timeout,
: Lower_Level_Lib :: No_Timeout);
LOWER_LEVEL_LIB_MACRO ("whatever");
}
As shown, the use of the Lower_Level_Lib function was not detected in my_library.h, so the application programmer does not need to know or enable lower_level_library.h. If you find that you need / want to put lower_level_library.h in my_library.h in order to use its types, constant, variables or functions in this case, you will also need to provide the application programmer with this library header.
source share