お世話になっております。
2時間調査をして解決できなかったのでお力を貸してください。
現在下記のエラーが出ております。
In file included from invider.c:5: inc/extern.h:15: error: expected declaration specifiers or ‘...’ before ‘mypositon_t’ invider.c: In function ‘main’: invider.c:58: error: too many arguments to function ‘move_right’ In file included from initialize.c:3: inc/extern.h:15: error: expected declaration specifiers or ‘...’ before ‘mypositon_t’ In file included from move.c:3: inc/extern.h:15: error: expected declaration specifiers or ‘...’ before ‘mypositon_t’ move.c:9: error: expected ‘)’ before ‘[’ token
どうやらmove_right関数に関係するextern 宣言もしくは、関数コール時の引数の指定に問題があるように見受けられました。
しかし根本的な原因を突き止められずにいます。
【extern.h】
#pragma once #include "macro.h" #include "display_info.h" extern void draw_pic(char display[DISPLAYROWMAX][DISPLAYCOLMAX]); /************************************/ /* initialize.c */ /************************************/ extern char initialize_main(char display[DISPLAYROWMAX][DISPLAYCOLMAX], myposition_t *position); // extern char initialize_top(char display[DISPLAYROWMAX][DISPLAYCOLMAX]); /************************************/ /* move.c */ /************************************/ extern char move_right(char display[DISPLAYROWMAX][DISPLAYCOLMAX], mypositon_t *position); // extern char move_left(myposition_t *position);
【invider.c】
#include <stdio.h> #include <termios.h> #include <unistd.h> #include <fcntl.h> #include "inc/extern.h" #include "inc/macro.h" /****************************************************************/ /* WindowsのkbhitはLinuxでは使えないため、termios機能を使用する */ /* kbhit関数はネットのを引用 */ /****************************************************************/ int kbhit(void){ struct termios oldt, newt; int ch; int oldf; tcgetattr(STDIN_FILENO, &oldt); newt = oldt; newt.c_lflag &= ~(ICANON | ECHO); tcsetattr(STDIN_FILENO, TCSANOW, &newt); oldf = fcntl(STDIN_FILENO, F_GETFL, 0); fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK); ch = getchar(); tcsetattr(STDIN_FILENO, TCSANOW, &oldt); fcntl(STDIN_FILENO, F_SETFL, oldf); if (ch != EOF) { ungetc(ch, stdin); return 1; } return 0; } /*****************************************************************/ /* メイン関数 */ /*****************************************************************/ int main(void){ char inputkey; //入力キー // int position; //自分のキャラの位置 myposition_t position = {0} ; char result = 0; //下位関数戻り値 char display [DISPLAYROWMAX][DISPLAYCOLMAX] = {' '} ; // ゲーム画面 char *first_flg ; initialize_main(display, &position); draw_pic(display) ; while (1) { if (kbhit()) { inputkey = getchar(); switch(inputkey){ case 'l': result = move_right(display, &position); if(result == 1){ continue; }else{ break ; } /* case 'h': result = move_left(&position); if(result == 1){ continue; }else{ break; } */ case 'q': goto exit; default: ; } } } exit: return 0; } void draw_pic(char display[DISPLAYROWMAX][DISPLAYCOLMAX]){ int loopcnt_row ; int loopcnt_col ; for(loopcnt_row = 0; loopcnt_row < DISPLAYROWMAX; loopcnt_row++){ for(loopcnt_col = 0; loopcnt_col < DISPLAYCOLMAX; loopcnt_col++){ printf("%c",display[loopcnt_row][loopcnt_col]); } } }
【move.c】
#include <stdio.h> #include "inc/macro.h" #include "inc/extern.h" /******************************************************************/ /* 自分のキャラを右に動かす関数 */ /******************************************************************/ char move_right(display[DISPLAYROWMAX][DISPLAYCOLMAX] ,myposition_t *position){ display[position->row][position->col] = ' ' ; /* 現在地初期化 */ display[position->row][position->col+1] = ' ' ; display[position->row][position->col+2] = ' ' ; if(position->col != 1 || position->col != 67){ /* _H_ の分で-3マス分 */ position->row = position->row +1 ; position->col = position->col +1 ; } display[position->row][position->col] = '_' ; /* _H_再生成 */ display[position->row][position->col+1] = 'H' ; display[position->row][position->col+2] = '_' ; }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/02 09:45