static void thread_intrでmakeエラー

閲覧: 2,032 回
最初の未読メッセージにスキップ

miwarin

未読、
2011/12/04 5:48:152011/12/04
To: KOZOS友の会
三輪です。

[環境]
* Microsoft Windows 7 64bit
* cygwin
* gcc 4.5.3
* binutils 2.22.51.20111013


[現象]
KOZOS のソースを http://kozos.jp/kozos/osbook_03.html からダウンロードしました。
8th ステップの src/08/os を make したところエラーになりました。

>>
rin@kotomi[/home/rin/work/OS/KOZOS/osbook/src/08/os]% make
/usr/local/bin/h8300-elf-gcc -c -Wall -mh -nostdinc -nostdlib -fno-
builtin -I. -Os -DKOZOS startup.s
/usr/local/bin/h8300-elf-gcc -c -Wall -mh -nostdinc -nostdlib -fno-
builtin -I. -Os -DKOZOS main.c
main.c: In function 'main':
main.c:17:3: warning: pointer targets in passing argument 1 of 'puts'
differ in signedness [-Wpointer-sign]
lib.h:14:5: note: expected 'unsigned char *' but argument is of type
'char *'
/usr/local/bin/h8300-elf-gcc -c -Wall -mh -nostdinc -nostdlib -fno-
builtin -I. -Os -DKOZOS interrupt.c
/usr/local/bin/h8300-elf-gcc -c -Wall -mh -nostdinc -nostdlib -fno-
builtin -I. -Os -DKOZOS lib.c
lib.c: In function 'putxval':
lib.c:132:3: warning: pointer targets in passing argument 1 of 'puts'
differ in signedness [-Wpointer-sign]
lib.c:93:5: note: expected 'unsigned char *' but argument is of type
'char *'
/usr/local/bin/h8300-elf-gcc -c -Wall -mh -nostdinc -nostdlib -fno-
builtin -I. -Os -DKOZOS serial.c
/usr/local/bin/h8300-elf-gcc -c -Wall -mh -nostdinc -nostdlib -fno-
builtin -I. -Os -DKOZOS kozos.c
kozos.c: In function 'thread_exit':
kozos.c:170:3: warning: pointer targets in passing argument 1 of
'puts' differ in signedness [-Wpointer-sign]
lib.h:14:5: note: expected 'unsigned char *' but argument is of type
'char *'
kozos.c:171:3: warning: pointer targets in passing argument 1 of
'puts' differ in signedness [-Wpointer-sign]
lib.h:14:5: note: expected 'unsigned char *' but argument is of type
'char *'
kozos.c: In function 'setintr':
kozos.c:179:15: error: invalid storage class for function
'thread_intr'
kozos.c:185:25: error: 'thread_intr' undeclared (first use in this
function)
kozos.c:185:25: note: each undeclared identifier is reported only once
for each function it appears in
kozos.c: In function 'softerr_intr':
kozos.c:239:3: warning: pointer targets in passing argument 1 of
'puts' differ in signedness [-Wpointer-sign]
lib.h:14:5: note: expected 'unsigned char *' but argument is of type
'char *'
kozos.c:240:3: warning: pointer targets in passing argument 1 of
'puts' differ in signedness [-Wpointer-sign]
lib.h:14:5: note: expected 'unsigned char *' but argument is of type
'char *'
kozos.c: In function 'kz_sysdown':
kozos.c:298:3: warning: pointer targets in passing argument 1 of
'puts' differ in signedness [-Wpointer-sign]
lib.h:14:5: note: expected 'unsigned char *' but argument is of type
'char *'
kozos.c: At top level:
kozos.c:246:13: warning: 'thread_intr' defined but not used [-Wunused-
function]
make: *** [kozos.o] エラー 1
<<


kozos.c の以下の部分です。

>>
/* 割込みハンドラの登録 */
static int setintr(softvec_type_t type, kz_handler_t handler)
{
static void thread_intr(softvec_type_t type, unsigned long sp);
←←←←←

/*
* 割込みを受け付けるために,ソフトウエア・割込みベクタに
* OSの割込み処理の入口となる関数を登録する.
*/
softvec_setintr(type, thread_intr);

handlers[type] = handler; /* OS側から呼び出す割込みハンドラを登録 */

return 0;
}
<<


ググってみると関数内で関数を宣言する「関数内宣言」というものでした。(初めて知った..)

static関数の前方宣言
http://developer.apple.com/jp/releasenotes/DeveloperTools/GCC40PortingReleaseNotes/Articles/PortingToGCC.html#104688


>>
GCC 4.0では、別の関数の本体内にstatic関数の前方定義を配置できません。
この状況を解決するには、関数の外に(ファイルの名前空間レベルに)前方定義を移動します。
<<


つまり static void thread_intr を外に出せばよいようです。

>>
+static void thread_intr(softvec_type_t type, unsigned long sp);
+
/* 割込みハンドラの登録 */
static int setintr(softvec_type_t type, kz_handler_t handler)
{
- static void thread_intr(softvec_type_t type, unsigned long sp);

/*
* 割込みを受け付けるために,ソフトウエア・割込みベクタに
<<


こんな対処でよいのでしょうか?

SAKAI Hiroaki

未読、
2011/12/04 6:07:202011/12/04
To: kozos_t...@googlegroups.com、hsa...@saturn.dti.ne.jp
坂井です.

以下の通り,static void thread_intr のプロトタイプ宣言を関数外に
出すことで対処してください.

理由もおっしゃるとおり,gccのバージョン4系では関数内での
プロトタイプ宣言ができないためです.

<46643dbe-0f29-446a...@r28g2000yqj.googlegroups.com>の記事において
miw...@gmail.comさんは書きました。

三輪晋( Miwa Susumu )

未読、
2011/12/04 7:39:332011/12/04
To: kozos_t...@googlegroups.com
三輪です。

2011年12月4日20:07 SAKAI Hiroaki <hsa...@saturn.dti.ne.jp>:


> 以下の通り,static void thread_intr のプロトタイプ宣言を関数外に
> 出すことで対処してください.
>
> 理由もおっしゃるとおり,gccのバージョン4系では関数内での
> プロトタイプ宣言ができないためです.

ありがとうございます。
ここはイケたようです。

--
みわ

全員に返信
投稿者に返信
転送
新着メール 0 件