gpt4 book ai didi

c - 非常简单的错误;我可能忘记了分号

转载 作者:行者123 更新时间:2023-11-30 16:03:58 25 4
gpt4 key购买 nike

我收到了很多这样的错误:

gfx.h:48: error: syntax error before 'buffer'

gfx.h:48: warning: type defaults to 'int' in declaration of 'buffer'

gfx.h:48: warning: data definition has no type or storage class

gfx.h:73: error: syntax error before 'uint16_t'

gfx.h:73: warning: no semicolon at end of struct or union

gfx.h:74: warning: type defaults to 'int' in declaration of 'visible_lines_per_frame'

gfx.h:74: warning: data definition has no type or storage class
...

我有点累,所以我不知道是什么原因造成的。

这是buffer的定义(从第43行开始,到第57行):

/* 8-bit architecture (not yet used.) */
#if PROC_BIT_SIZE == 8
uint8_t buffer[GFX_SIZE];
# define GFX_PIXEL_ADDR(x,y) (x / 8) + (y * (GFX_WIDTH / 8))
/* 16-bit architecture: dsPIC */
#elif PROC_BIT_SIZE == 16
uint16_t buffer[GFX_SIZE / 2];
# define GFX_PIXEL_ADDR(x,y) (x / 16) + (y * (GFX_WIDTH / 16))
/* 32-bit architecture: AVR32(?), STM32 */
#elif PROC_BIT_SIZE == 32
uint32_t buffer[GFX_SIZE / 4];
# define GFX_PIXEL_ADDR(x,y) (x / 32) + (y * (GFX_WIDTH / 32))
/* Other, unknown bit size.*/
#else
# error "processor bit size not supported"
#endif

(它旨在支持多种架构8位MCU到32位MCU。)

我定义了 uint8_t 等,因为我使用的 GCC 似乎没有 stdint.h header 。

这是我定义 uint8_t 等的方式。

/* 
* stdint.h support.
* If your compiler has stdint.h, uncomment HAS_STDINT.
*/
//#define HAS_STDINT
#ifndef HAS_STDINT
// D'oh, compiler doesn't support STDINT, so create our own,
// 'standard' integers.
# if PROC_BIT_SIZE == 8 || PROC_BIT_SIZE == 16
typedef char int8_t;
typedef int int16_t;
typedef long int32_t;
typedef long long int64_t;
typedef unsigned char uint8_t;
typedef unsigned int uint16_t;
typedef unsigned long uint32_t;
typedef unsigned long long uint64_t;
# elif PROC_BIT_SIZE == 32
typedef char int8_t;
typedef short int16_t;
typedef int int32_t; // usually int is 32 bits on 32 bit processors, but this may need checking
typedef long int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long uint64_t;
# endif
#else
# include <stdint.h>
#endif

最佳答案

警告:结构或 union 末尾没有分号意味着您在结构 union 末尾留下了分号 code> 先前在同一文件中或先前包含的另一个 header 中定义。这会导致格式错误的语句,例如:

struct S { ... } uint8_t buffer[GFX_SIZE];

关于c - 非常简单的错误;我可能忘记了分号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3662759/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com