Writing a C code in Arduino libraries

Hi,

What is the benefit of using:

#ifdef __cplusplus
    extern "C" {
#endif


#ifdef __cplusplus
    }
#endif

And where should I use it ? in header file or in source file or both ?

See the third use for the extern keyword:

I have another question:

If I declared a struct in "task_manager.h"; like this:

// structs
typedef struct {
	uint8_t (*fun_ptr)();
    uint32_t task_st;
    uint32_t task_pr;
    bool task_start_lock;
    bool task_full_lock;
}TASK_MANAGER;

static TASK_MANAGER *task_ptr;

My questions, is the declaration of the pointer correct to be used along other source files ?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.