-3
イム私のような定義された関数持たC.に新しい:Cが正しく機能していませんか?
U16は、符号なしshortを意味void drawImage3(int x, int y, int width, int height, const u16* image);
:私はこれを持って私のメインプログラムに含ま.hファイルで
/*
* 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ファイルである:別の時間ファイルに
extern unsigned short *videoBuffer;
extern const unsigned short *pt;
は1024 constの符号なし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を作った。
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
また、ヘッダファイルに'extern'以外の変数を宣言することは、普通は悪い考えです。 –