Johnson077
2018-10-23 12:02
采纳率: 100%
浏览 1.1k

Linux下编程遇到的转换错误,要如何修改?

main.cc:118:43: error: invalid conversion from ‘void*’ to ‘_u32* {aka unsigned int*}’ [-fpermissive]
cache->addr_list = realloc(cache->addr_list, cache->addr_list_size * sizeof(_u32));
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cc: In function ‘void reset_cache_sim(cache_sim*, int, int)’:
main.cc:179:42: error: invalid conversion from ‘void*’ to ‘_u8* {aka unsigned char*}’ [-fpermissive]
cache->cache_buf = malloc(cache->cache_size);
~~~~~~^~~~~~~~~~~~~~~~~~~
main.cc:189:31: error: invalid conversion from ‘void*’ to ‘cache_item*’ [-fpermissive]
cache->caches = malloc(sizeof(struct cache_item) * cache->cache_item_num);
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cc: In function ‘void load_trace(cache_sim*, char*)’:
main.cc:361:51: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
do_cache_op(cache, (void*)addr, 1);
^~~~
main.cc:364:51: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
do_cache_op(cache, (void*)addr, 0);
^~~~
main.cc: At global scope:
main.cc:411:55: error: ISO C++ forbids declaration of ‘do_test’ with no type [-fpermissive]
static do_test(struct cache_sim* cache, char* filename)
^
main.cc: In function ‘int main(int, char**)’:
main.cc:429:94: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
st_cases[] = {"gcc.trace","gzip.trace","mcf.trace","swim.trace","twolf.trace"};
^
main.cc:429:94: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
main.cc:429:94: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
main.cc:429:94: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
main.cc:429:94: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]

错误描述是这样的,求大神解答

1条回答 默认 最新

相关推荐 更多相似问题