When to use a .C library vs a .CPP library


i copying wiring_serial library testing.  i want create new "test_serial" mods.  hopefully avoids risks of continuing edit core code.  

my question is, hardwareserial.cpp appears call "wiring.serial.c"  presumably put c++ face on it.   there reason cannot make new library .cpp start with?  it looks can hook interrupts in .cpp.   or matter there problem creating .c library , distributing it?


feel free make libraries written in c++.  i think existing libraries don't go out , make c++ syntax less confusing newcomers or c programmers, c++ can serve needs of small programs c.

if you're going make c library functions usable user's c++ sketch, need ensure header file explicit c nature.

mylibrarywritteninc.h
code: [select]

[glow]#ifdef __cplusplus
extern c {
#endif[/glow]

/* prototypes functions implemented in c */
int mycfunction(float, char, int);

[glow]#ifdef __cplusplus
} // extern c
#endif[/glow]


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > When to use a .C library vs a .CPP library


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums