This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Why is ble_cus.c not a header file

In this tutorial

github.com/.../custom_ble_service_example

There are two additional files added to the template project

ble_cus.c
ble_cus.h

I understand that ble_cus.h must be included as a header in both ble_cus.c and main.c

However, my code doesn't compile unless I also #include ble_cus.c in main.c like this

// main.c
#inlcude ble_cus.c
#inlcude ble_cus.h

My question is, why isn't ble_cus.c defined as a header file i.e. with a .h extension? What is the purpose of making it a .c file? Am I missing something?

Additionally, if ble_cus.h is included as a header in ble_cus.c then don't I only have to #include ble_cus.c in main.c?

// main.c
#inlcude ble_cus.c
//#inlcude ble_cus.h

Thanks

Related