-3
进出口新的C.我有一个函数定义为这样: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 = ℑ
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文件I包括在我的主程序我有这样的:
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 const的无符号短数组。
在我的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。
Program.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
是不是第一个错误,因为[你以前的问题](http://stackoverflow.com/questions/6639256/pointer-to-first-element-in-array-c)相同的问题? –
请发布main.c文件的第一部分。 – Perception
此外,在头文件中声明非'外部'变量通常是一个坏主意。 –