You can overload functions in C++ (same name, different arguments) so you could do:
Code:
void serial_print(unsigned port, int x)
{
// Convert int to string/const char* here using stringstream
serial_port(port,converted_int_value_as_const_char_ptr); // Call the other "string" version
}
void serial_print(unsigned port, const char* blah)
{
// Do your usual stuff to write data here
}
Then you could call either one depending on what type of data you have:
Code:
int value;
...
serial_print(COM0_USER,value); // Call int version
serial_print(COM0_USER,"your string here"); // Call const char* version