vc和gcc对C语言数据类型长度的定义

vc2010中......

测试代码:

#include <stdio.h>
#include <iostream>                  

int main()
{
	printf("in windows ...\n");
	int l_char=sizeof(char);
	printf("char ----> %d\n",l_char);
	int l_int=sizeof(int);
	printf("int ----> %d\n",l_int);
	int l_short=sizeof(short);
	printf("short ----> %d\n",l_short);
	int l_long=sizeof(long);
	printf("long ----> %d\n",l_long);
	int l_float=sizeof(float);
	printf("float ----> %d\n",l_float);
	int l_double=sizeof(double);
	printf("double ----> %d\n",l_double);
	int l_ldouble=sizeof(long double);
	printf("long double ----> %d\n",l_ldouble);

	system("pause");
	return 0;
}

运行结果:


gcc中 ......

测试代码:

#include <stdio.h>

int main()
{
        printf("in linux ...\n");
        int l_char=sizeof(char);
        printf("char ----> %d\n",l_char);
        int l_int=sizeof(int);
        printf("int ----> %d\n",l_int);
        int l_short=sizeof(short);
        printf("short ----> %d\n",l_short);
        int l_long=sizeof(long);
        printf("long ----> %d\n",l_long);
        int l_float=sizeof(float);
        printf("float ----> %d\n",l_float);
        int l_double=sizeof(double);
        printf("double ----> %d\n",l_double);
        int l_ldouble=sizeof(long double);
        printf("long double ----> %d\n",l_ldouble);
        return 0;
}

运行结果:


可见在long double的长度定义上vc和gcc不一样,其他的都差不多。

你可能感兴趣的:(c,gcc,VC)