I'm using clang++ 13.0.1
The code below works but it's obviously ugly. How do I write a strlen? -Edit- Inspired by the answer, it seems like I can just implement strlen myself
#include <cstdio>
constexpr int test(const char*sz) {
if (sz[0] == 0)
return 0;
if (sz[1] == 0)
return 1;
if (sz[2] == 0)
return 2;
return -1;
//return strlen(sz);
}
constinit int c = test("Hi");
int main() {
printf("C %d\n", c);
}