IntelliSense error: identifier "strlcpy" is undefined

Indeed,

#include <Arduino.h>

void setup() {}
void loop() {
 const char *s = "test";
 char buf[64];
 strlcpy(buf, s, sizeof(buf));    
}

does compile but show a VSCode intellisense ‘error’. The source of error is the same as in Identifier is undefined - setenv tzset. PlatformIO does not seem to define _BSD_SOURCE as a macro in the intellisense config, and so some non-standard functions are not found.

From string.h:

#if __BSD_VISIBLE
size_t	strlcat (char *, const char *, size_t);
size_t	strlcpy (char *, const char *, size_t);
#endif

(_BSD_SOURCE enables a lot of other macros, such as __BSD_VISIBLE).

So the fix, adding build_flags = -D_BSD_SOURCE to the platformio.ini, is also valid there.

EDIT: Enabling _GNU_SOURCE also does the trick.