hello support
What is this Line in ble_lbs_c.h
#define BLE_LBS_C_H__
and in ble_lbs.h
#define BLE_LBS_H__
hello support
What is this Line in ble_lbs_c.h
#define BLE_LBS_C_H__
and in ble_lbs.h
#define BLE_LBS_H__
This is known as "header guards", and is implemented in the following manner:
#ifndef BLE_LBS_C_H__ #define BLE_LBS_C_H__ . . . . #endif // BLE_LBS_C_H__
The purpose of these lines is to avoid the header file to be included twice. Multiple inclusions of header files leads to multiple declarations of functions and structs, which makes the translation unit invalid.
If two source files includes the header file ble_lbs_c.h, the first source file to enter the preprocessing stage will get a copy of the content, while the second source file won't get any content, since #ifndef BLE_LBS_C_H__ evaluates as false.
Read more about header guards here
Best regards,
Simon
thanks Simon
Eh ! I understand that..
I want to know #define BLE_LBS_C_H__
this preprocessor directive has no value for example #define MACRONAME value
The use of a preprocessor directives without a value is sufficient for it to act as a header guard. The check #ifndef BLE_LBS_C_H__ will only check whether it is defined or not, and giving the preprocessor directive a value serves no purpose.
The use of a preprocessor directives without a value is sufficient for it to act as a header guard. The check #ifndef BLE_LBS_C_H__ will only check whether it is defined or not, and giving the preprocessor directive a value serves no purpose.