我不明白爲什麼會觸發此警告!警告:從不同大小的整數轉換爲指針[-Wint-to-pointer-cast] c編程
test.c的:920:56:警告:投給指針從不同大小的整數[-Wint到指針鑄]
如果((的memcpy((無效*)(buffer_post_offset +位置),(無效*)data_block_n,bytes_to_write))== NULL){
這裏是一段代碼...
char *buffer_post_offset = NULL;
// ....
// Gets the data between offset and size
for(i = 0, data_block_n = start_at, position = 0, bytes_to_write = 0; data_block_n <= finish_at; ++data_block_n, ++i, position += bytes_to_write){
// Gets from disk the sector/block of data
if(Disk_Read(data_block_n, sector_str_data) == FAIL){
osErrno = E_GENERAL;
return FAIL;
}
// Calculates how many bytes are to be written
bytes_to_write = SECTOR_SIZE;
if(data_block_n == finish_at)
bytes_to_write -= inode.size - open_files_table.table[fd]->offset % SECTOR_SIZE;
// Gets more memory for the buffer
if((buffer_post_offset = (void *) realloc((void *) buffer_post_offset, (i + 1) * bytes_to_write * sizeof(char))) == NULL){
osErrno = E_GENERAL;
return FAIL;
}
// Writes into the buffer that store the data between offset and size
// GETTING THE WARNING ON THE NEXT LINE !!!!!!
if((memcpy((void *) buffer_post_offset + position, (void *) data_block_n, bytes_to_write)) == NULL){
osErrno = E_GENERAL;
return FAIL;
}
}
什麼是data_block_n?我想這是一個整數 – 2014-10-30 00:42:47
你爲什麼這樣做?這太糟糕了! – 2014-10-30 00:45:58
C或C++?另外,爲什麼那些過長的行,不要讓我們滾動?! – Deduplicator 2014-10-30 00:50:59