Я новичок в 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, который я включаю в основную программу, у меня есть это:
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 шаров без знака.
В моем файле 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