我收到编译错误在项目code,其中的情况如下:
I am getting compilation error in a Project Code where the situation is as follows:
typedef unsigned int U32bit; typedef unsigned long long U64bit; U32bit var; U64bit var2; var = function(); /* Function returns a 32-bit value, which is stored in var */ var2 = 100*var1; /* 100*var1 is very Big & can be stored only in U64bit variable */ For the Above Line: var2 = 100*var1我收到以下编译错误在Solaris上:
I am getting the following Compilation Error on Solaris:
"conversion to non-scalar type requested"我也曾尝试类型转换:
I have also tried typecasting:
var2 = (U64bit) 100*var1;这也给出了同样的错误。
This also gives the same error.
推荐答案标准的固定宽度整数类型 uint32_t的和 uint64_t中,尝试这些。那么该类型的常量可以用定义UINT64_C(100)。
The standard fixed-width integer types in C are uint32_t and uint64_t, try with these. Then a constant of that type can be defined with UINT64_C(100).
要拥有这些类型的,你可能必须添加
To have these types you might have to add
#include <stdint.h>您包括