#define LITERAL "foo"

if (!strnmp(str, LITERAL, strlen(LITERAL))) {
}