NCurses:如何确定是否支持 ABI 6?

NCurses: how to find out whether ABI 6 is supported?

有没有办法查明 ncurses 是否支持 ABI 6?

if ( ABI 6 is supported ) {
    ...
}
else {
    ...
}

你可以通过比较头文件来看出这一点。有两个特性可以在编译时检查:

  • 头文件中的鼠标版本不同:
     /*                                                                             
      * Identify the mouse encoding version.                                        
      */                                                                            
    -#define NCURSES_MOUSE_VERSION 1                                                
    +#define NCURSES_MOUSE_VERSION 2
  • 扩展颜色符号已定义:
    @@ -374,9 +419,9 @@                                                             
     {                                                                              
         attr_t     attr;                                                           
         wchar_t    chars[CCHARW_MAX];                                              
    -#if 0                                                                          
    +#if 1                                                                          
     #undef NCURSES_EXT_COLORS                                                      
    -#define NCURSES_EXT_COLORS 20110404                                            
    +#define NCURSES_EXT_COLORS 20170729                                            
         int                ext_color;      /* color pair, must be more than 16-bits */
     #endif                                                                         
     }

也就是说,后者(在 ABI 5 中)在一个 ifdef 中,它阻止 NCURSES_EXT_COLORS 符号被定义。 NCURSES_MOUSE_VERSION 符号总是被定义,但它的值改变了。