gpt4 book ai didi

C 没有正确看到我的函数?

转载 作者:行者123 更新时间:2023-11-30 21:04:39 24 4
gpt4 key购买 nike

我是 C 新手。我有一个定义如下的函数:

/*
* Draws an image in mode3 USING DMA.
* int x x coordinate
* int y y coordinate
* int width Width of the image (Note may not be the same width as the GBA)
* int height Height of the image (Note may not be the same height as the GBA)
* const u16* pointer to the first element in the image
*/
void drawImage3(int x, int y, int width, int height, const u16* image)
{
int r;
for (r=0; r<height; r++) {

DMA[3].src = &image;
DMA[3].dst = &videoBuffer[OFFSET(x+width, y, 240)];
DMA[3].cnt = width | DMA_SOURCE_FIXED| DMA_ON | DMA_DESTINATION_INCREMENT;
image = &image + (r * width);

}

}

在我的主程序中包含的 .h 文件中,我有以下内容:

void drawImage3(int x, int y, int width, int height, const u16* image);

其中 u16 表示无符号短整型,并在其他地方定义。

这些也都在我的 .h 文件中:

extern unsigned short *videoBuffer;
extern const unsigned short *pt;

在另一个 h 文件中是一个由 1024 个常量无符号 Short 组成的数组。

在我的 main.c 文件中,我这样调用我的函数:

pt = imgArray;
drawImage3(25,25, img_WIDTH, img_HEIGHT, pt);

我收到很多错误。

Program.c:22: error: data definition has no type or storage class
Program.c:22: error: type defaults to 'int' in declaration of 'pt'
Program.c:22: error: conflicting types for 'pt'
myLib.h:21: note: previous declaration of 'pt' was here
Program.c:22: error: initializer element is not constant
Program.c:23: error: expected declaration specifiers or '...' before numeric constant
Program.c:23: error: expected declaration specifiers or '...' before numeric constant
Program.c:23: error: expected declaration specifiers or '...' before numeric constant
Program.c:23: error: expected declaration specifiers or '...' before numeric constant
Program.c:23: error: expected declaration specifiers or '...' before 'pt'
Program.c:23: error: data definition has no type or storage class
Program.c:23: error: type defaults to 'int' in declaration of 'drawImage3'
Program.c:23: error: conflicting types for 'drawImage3'
myLib.h:117: note: previous declaration of 'drawImage3' was here

对这里发生的事情有什么想法吗?

--------编辑

是的,奥利,你对第一个错误的看法是正确的。谢谢!我已经编辑了我的函数,并且该错误消失了。我还制作了我的 *pt 和 extern。

程序.c:

//Philip Johnson
#include <stdio.h>
#include "img.h"
#include <unistd.h>
#include "myLib.h"
#include "text.h"

typedef struct // This typedef defines a new type called MOVOBJ
{ // which are structures that hold all the info for
int row; // a single movable object
int col;
int rdel;
int cdel;
u16 color;

} MOVOBJ;

MOVOBJ newcharacter, car1, car2, car3;
int size = 5;
int speed = 2;
int checkforend = 0;
pt = imgArray;
drawImage3(25,25, img_WIDTH, img_HEIGHT, pt);
int main(){ //....and so on from there

最佳答案

您的意思可能是 u16* pt = imgArray; - 如果您在 C 中声明新变量,则必须给出类型。

关于C 没有正确看到我的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6641657/

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