Yes, but it's recommended to use a standard include guard instead of #pragma once. The only thing I've used #pragma for is #pragma message to display a message for the user in the compilation output, rather than using #warning for that purpose.
I don't understand your question. Are there cases when you don't want to #include <RealTimeClockDS1307.h>? If so, can't you leave it to the programmer to include that header in the .ino file?
comments:
char strDayMonthName[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
const char* getMonthName(const uint8_t nMonthNum, const bool bShort)
{
memset(strDayMonthName, 0, 10);
if (nMonthNum == 1)
strcpy(strDayMonthName, "January");
else if (nMonthNum == 2)
strcpy(strDayMonthName, "February");
else if (nMonthNum == 3)
strcpy(strDayMonthName, "March");
else if (nMonthNum == 4)
strcpy(strDayMonthName, "April");
else if (nMonthNum == 5)
strcpy(strDayMonthName, "May");
else if (nMonthNum == 6)
strcpy(strDayMonthName, "June");
else if (nMonthNum == 7)
strcpy(strDayMonthName, "July");
else if (nMonthNum == 7)
strcpy(strDayMonthName, "August");
else if (nMonthNum == 7)
strcpy(strDayMonthName, "September");
else if (nMonthNum == 7)
strcpy(strDayMonthName, "October");
else if (nMonthNum == 7)
strcpy(strDayMonthName, "November");
else if (nMonthNum == 7)
strcpy(strDayMonthName, "December");
else
strcpy(strDayMonthName, "Invalid day number");
if ((strlen(strDayMonthName) > 3) && bShort)
strDayMonthName[3] = 0;
return strDayMonthName;
}
how does "Invalid day number" fit into a 10 element char array?
you should use strcpy's safer cousin: strncpy
actually, why build the string to return? you are wasting memory using that strDayMonthName buffer
why are you not using arrays? Just return a pointer to the string constant held in an arry...
I did try my best, but basically each .h/.cpp pair gets compiled to object files first so each pair needs to have its own and correct #includes.
Standard #ifndef#includes guard or #pragma is still required if the #includes headers /cpp have multiple entries so the .h /.cpp pair uses them only once.