如图所示,按照官网提供的例程读取tiff文件,并打印读取的值时,提示:
Subscript of pointer to incomplete type 'void'
代码如下:
//---打开tiff文件的测试TIFF* tif = TIFFOpen("a.tif", "r");if(tif){uint32 imageLength;tsize_t scanline;
// unsigned char* buf;tdata_t* buf;uint32 row;uint32 col;TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imageLength);scanline = TIFFScanlineSize(tif);
// buf = (unsigned char *)_TIFFmalloc(scanline);buf = (tdata_t*)_TIFFmalloc(scanline);printf("Scanlinesize = %zu", scanline);// %zu用来打印tsize_tfor(row=0;row
报错情况如图所示:
报错原因:
可能是buf 类型在分配内存的时候应该是指针类型,如下:
buf = (unsigned char *)_TIFFmalloc(scanline);
// buf = (tdata_t*)_TIFFmalloc(scanline);
使用tdata_t* 和unsigned char *类型都可以编译成功,但是打印出的数据不同:
tdata_t* 时,打印的数据如下:

使用unsigned char * 时,打印的数据如下:

貌似使用unsigned char * 时获取的数据应该是正确的。