Typedef Bug /错误 [英] Typedef Bug/Error
问题描述
#include< stdio.h>
int main()
{
typedef int R1;
typedef int R2;
typedef long int R3;
无符号R1 n1;
长R2 n2;
R3 n3;
n1 = 123456789;
n2 = 123456789;
n3 = 123456789;
printf("%u ..%d \ n",n1,sizeof(n1));
printf("%ld ..%d \ n" ,n2,sizeof(n2));
printf("%ld ..%d \ n",n3,sizeof(n3));
返回0 ;
}
获取以下错误..,
在n1之前的Teast2.c语法错误
Teast2.c之前的语法错误n2
Teast2.c`n1''未声明(首次在此函数中使用)
Teast2.c`n2 ''未宣布(首次使用此功能)
#include<stdio.h>
int main()
{
typedef int R1;
typedef int R2;
typedef long int R3;
unsigned R1 n1;
long R2 n2;
R3 n3;
n1=123456789;
n2=123456789;
n3=123456789;
printf("%u..%d\n",n1,sizeof(n1));
printf("%ld..%d\n",n2,sizeof(n2));
printf("%ld..%d\n",n3,sizeof(n3));
return 0;
}
Getting Following Errors..,
Teast2.c syntax error before "n1"
Teast2.c syntax error before "n2"
Teast2.c `n1'' undeclared (first use in this function)
Teast2.c `n2'' undeclared (first use in this function)
推荐答案
On Mon,01 Sep 2008 10:43:54 -0700,Pranav写道:
On Mon, 01 Sep 2008 10:43:54 -0700, Pranav wrote:
typedef int R1;
无符号R1 n1;
typedef int R1;
unsigned R1 n1;
typedef不是宏。您将R1定义为(signed)int的typedef。你
以后不能签名。
typedefs are not macros. You defined R1 as a typedef for (signed) int. You
cannot make it unsigned later.
9月1日晚上10点51分,Harald van D?| k< true .. 。@ gmail.comwrote:
On Sep 1, 10:51 pm, Harald van D?|k <true...@gmail.comwrote:
On Mon,01 Sep 2008 10:43:54 -0700,Pranav写道:
On Mon, 01 Sep 2008 10:43:54 -0700, Pranav wrote:
typedef int R1;
unsigned R1 n1;
typedef int R1;
unsigned R1 n1;
typedef不是宏。您将R1定义为(signed)int的typedef。你
以后不能使它无符号。
typedefs are not macros. You defined R1 as a typedef for (signed) int. You
cannot make it unsigned later.
K ...,这就是问题..,谢谢Harald van D?| k ..,
K..., Here Lies The Problem.., Thank You Harald van D?|k..,
>
Harald van D?| k< true ... @ gmail.comwrote:
Harald van D?|k <true...@gmail.comwrote:
Pranav写道:
Pranav wrote:
typedef int R1;
无符号R1 n1;
typedef int R1;
unsigned R1 n1;
typedef不是宏。您将R1定义为typedef
(签名)int。你以后不能将它取消签名。
typedefs are not macros. You defined R1 as a typedef
for (signed) int. You cannot make it unsigned later.
因此为什么< stdint.htypedefs uintN_t以及intN_t。
请注意,CHAR_BIT == 32的C99实现必须
提供uint32_t,但不需要提供int32_t。
-
Peter
Hence why <stdint.htypedefs uintN_t as well as intN_t.
Note that a C99 implementation with CHAR_BIT == 32 must
provide uint32_t, but it need not provide int32_t.
--
Peter
>
这篇关于Typedef Bug /错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!