使用zlib1.2.3内存操作时,zlib定义的输入内存块变量next_in为: typedef struct z_stream_s ...{ Bytef *next_in; /**//* next input byte */ ...} z_stream; 所以无法将const char * 的变量直接设为next_in。被迫使用const_cast。 zs.next_in = const_cast<Bytef *>(pInput); zlib 其它地方广泛使用const,不知为何此处没有限定const。 (转载请注明来源于金庆的专栏)