0
点赞
收藏
分享

微信扫一扫

被迫使用const_cast



使用zlib1.2.3内存操作时,zlib定义的输入内存块变量next_in为:

zlib 其它地方广泛使用const,不知为何此处没有限定const。

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);



 

举报

相关推荐

0 条评论