On Fri, 21 Dec 2018 14:20:25 -0800 Joe Perches <j...@perches.com> wrote:
> static inline bool str_has_prefix(const char *str, const char prefix[]) > { > return !strncmp(str, prefix, strlen(prefix)); > } > > eliminates the strlen with gcc 4.8 (oldest I still have) I tested it a bit more before posting. I tested it against: gcc 4.5.1, 4.5.4, 4.6.3, 6.2.0, 7.2.0 and 8.2 And the strlen was eliminated each time. So this looks like the right approach :-) -- Steve