在编译gRPC的过程中发现编译到最后弹出如下错误提示:
1 | [PROTOC] Generating protobuf CC file from src/proto/grpc/channelz/channelz.proto |
Something interesting
在编译gRPC的过程中发现编译到最后弹出如下错误提示:
1 | [PROTOC] Generating protobuf CC file from src/proto/grpc/channelz/channelz.proto |
轮子哥的解释:
顶层和底层的翻译很容易让人误解为就只有两层,实际上当然是不是的。首先我们假设有这样的代码:template
using Const = const T;
templateusing Ptr = T*;
然后const int *** const shit = nullptr;
要怎么看呢?很简单,不要用const和*,用Const和Ptr来表达,马上明白:Const<Ptr<Ptr<Ptr<Const>>>> shit = nullptr;
一秒学会
最近在用phabricator的时候有一个cpp文件被识别为bin文件了。查看之后发现上次push中有一个非utf-8字符,导致文件的编码格式变成了ISO-8859
今天看到代码里有一段这样的操作:
1 | int getline(std::string &str, FILE *fp) { |
第一反应是这句str = buf
不是把buf的指针赋给str,然后free不是啥都没了吗?后来仔细看了看,其实std::string的赋值操作符是重载的,有一个定义是:
1 | string& operator= (const char* s); |
buf是直接把内容赋给了str,和指针无关了。