1.可以返回字符串常量,但是不能返回char buf[BUF_SIZE]
char* get_str(){char* str = "hello world";return str;
}char* get_str(){char str[32] = {0};strcpy(str, "hello world");return str;
}//err
2.联合体不能用指针,也不能memset 0,因为大小不固定,直接报错
struct addr{union {struct{u32 addr;u32 mask;}ipv4;struct{u32 addr;u32 mask;}ip...;}ip;
};
3.strlen和strncpy等都有无法传unsigned char*的编译器,这个时候自己强转一下就好了
mscc里可以unsigned char* a= "hello";printf("a:{%s}, len:[%d]\n", a, strlen(a));有的gcc要自己转unsigned char* a= (unsigned char*)"hello";printf("a:{%s}, len:[%d]\n", (char*)a, strlen((char*)a));