Search code examples
c++arduinostrncmp

Difference between strncmp_P and strncmp_PF on Arduino?


What is the difference between strncmp_P and strncmp_PF on Arduino? I understand strncmp_F, but what is purpose of strncmp_PF?


Solution

  • There are two address spaces on Arduino: SRAM and Program memory (Flash).

    You can refer to program memory using a normal "near" pointer, or a special "far" pointer to access more memory than is normally possible (e.g. near pointers can only access 64KB of program memory on a 16-bit CPU).

    strncmp_P and strncmp_PF both compare with strings in program memory (as opposed to strncmp, which compares two strings from SRAM), but strncmp_PF takes a far pointer while strncmp_P takes a normal near pointer. That's the only difference.