Getchの例題も動かない

同じ本の324ページの、Getchの例題2、Getch2.cをやってみる。
どうやら同じ個所でエラーになるみたい。全部貼ると、

make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory ‘D:/Dropbox/PIC/C_PICbook/Getch2.X’
make -f nbproject/Makefile-default.mk dist/default/debug/Getch2.X.debug.elf
make[2]: Entering directory ‘D:/Dropbox/PIC/C_PICbook/Getch2.X’
“D:\Program Files\Microchip\xc8\v2.45\bin\xc8-cc.exe” -mcpu=16F18857 -c -D__DEBUG=1 -mdebugger=none -mdfp=”D:/Program Files/Microchip/MPLABX/v6.15/packs/Microchip/PIC16F1xxxx_DFP/1.19.363/xc8″ -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx32 -Wl,–data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -mno-default-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto -o build/default/debug/Getch2.p1 Getch2.c
make[2]: *** [build/default/debug/Getch2.p1] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
Getch2.c:17:6: error: conflicting types for ‘getch’
char getch(void);
^
D:\Program Files\Microchip\xc8\v2.45\pic\include\c99\stdio.h:96:5: note: previous declaration is here
int getch(void);
^
Getch2.c:25:16: warning: implicit conversion loses integer precision: ‘int’ to ‘char’ [-Wconversion]
data = getch();
~ ^~~
Getch2.c:42:6: error: conflicting types for ‘getch’
char getch(void){
^
D:\Program Files\Microchip\xc8\v2.45\pic\include\c99\stdio.h:96:5: note: previous declaration is here
int getch(void);
^
1 warning and 2 errors generated.
(908) exit status = 1
nbproject/Makefile-default.mk:92: recipe for target ‘build/default/debug/Getch2.p1’ failed
make[2]: Leaving directory ‘D:/Dropbox/PIC/C_PICbook/Getch2.X’
nbproject/Makefile-default.mk:85: recipe for target ‘.build-conf’ failed
make[1]: Leaving directory ‘D:/Dropbox/PIC/C_PICbook/Getch2.X’
nbproject/Makefile-impl.mk:39: recipe for target ‘.build-impl’ failed

BUILD FAILED (exit value 2, total time: 504ms)

うーん。getchをやろうとすると、タイプが競合してエラーになると?なんだこれ??

調べたらこういうのが現れた。

That error is due to a MCC/Melody issue. The correct declaration is int getch(void);, so you need to change the declaration in eusart.c line 141. It may have started with XC8 v2.41 when the declaration was added to stdio.h; the declaration was technically correct, but conflicts with the technically incorrect version in the Melody code. The C99 compiler enforces the rule that all the declarations must match, but the (older) C90 compiler did not. The video is probably old enough to miss the bug.

A note on your post: please state the name of the micro itself (pic16f18446) when asking questions. The CNano board numbers are not very well known, so getting straight to the device name helps others understand what you are working on. Had to watch the video to see which micro you were working with! 😀

EDIT: Just realized that the DM164137 is not the board in the video. Which device are you actually working with?

うーん・・・・どうしろとwww eusart.cの141行って何だ?なんでいきなり出てくるのか不明。
XC8のv.2.41になって、stdio.hに変なのが加わったのが原因で、なんか知らないけどC99とC90のコンパイラでいざこざが発生したと?まるで、バンドやオケや町内会の人間関係のトラブルみたいだなwww(^^♪ ハードウェアの不具合なら、オシロやスペアナで波形を見れば物理現象として原因を特定できるが、ソフトのエラーって、こういうふうに人間関係のトラブルが原因で起こる??から、ソフトは大嫌いだ!www(^^)/ 本当かよ??

PICをやめる・・・という選択肢もあるわけで。まあどうでもいいことにしよう(^^♪


※追記、別にPICに限らず、windowsでも、どうでもいい無駄な機能を勝手にくっつけて、それが原因でエラーが起きて動いていたものも動かなくなるということがこの世では頻繁に起こるのだが、こういうのって、無駄な機能を付けないとソフト屋がメシの食い上げになるのが原因なの?全世界的に見れば大いなる無駄だと思うんだけど。ある意味資本主義の構造的欠陥なのか?まあこういう話題は手に余るから無視することにしよう。(^^♪

コメント

タイトルとURLをコピーしました