stdcout --- int64_t type --- stdendl;int64_t free_int = static_castint64_tfree_byte;int64_t total_int = static_castint64_ttotal_byte;int64_t free_int_g = free_int 1024 1024 1024;int64_t total_in
The error is occurring because you are trying to declare a variable named "free_int" twice in the same scope. The first declaration is as an int64_t type and the second declaration is as an int type.
To fix this error, you need to choose a different name for one of the variables. For example:
std::cout << "--- int64_t type ---" << std::endl;
int64_t free_int64 = static_cast<int64_t>(free_byte);
int64_t total_int64 = static_cast<int64_t>(total_byte);
int64_t free_int_g = free_int64 / 1024 / 1024 / 1024;
int64_t total_int_g = total_int64 / 1024 / 1024 / 1024;
std::cout << "Total global memory: " << total_int_g << "G" << std::endl;
std::cout << "Total available memory: " << free_int_g << "G" << std::endl;
Now, the variable names are unique and the code should compile without any conflicts.
原文地址: https://www.cveoy.top/t/topic/ixiz 著作权归作者所有。请勿转载和采集!