3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

z88dk zcc バグと回避

Last updated at Posted at 2018-07-18

zcc - Frontend for the z88dk Cross-C Compiler - v12228-3adc863-20180704

  • 症状

for文でbreakを使うと挙動がおかしくなる。

test.c
/*
z88dk / WebMSX
zcc +msx -lndos -create-app -bntest test.c
*/

#include <stdio.h>

void main()
{
	for (int i = 0; i < 10; i++) {
		if (i >= 5) break;
		printf("%d\n", i);
	}
}
  • 回避策

変数宣言をfor文の外に出す。

test.c
/*
z88dk / WebMSX
zcc +msx -lndos -create-app -bntest test.c
*/

#include <stdio.h>

void main()
{
	int i;
	for (i = 0; i < 10; i++) {
		if (i >= 5) break;
		printf("%d\n", i);
	}
}
  • 症状

floatの比較がおかしい。

  • 回避策

条件をいろいろ変えてみる。

test.c
/*
z88dk / WebMSX
zcc +msx -lndos -lm -create-app -bntest test.c

PC6001V / cload, run
zcc +pc6001 -lm -create-app -subtype=32k -bntest test.c
*/

#include <stdio.h>

void main()
{
	float f = 0;

	if (4 < f) {
		printf("true\n");
	} else {
		printf("false\n");
	}

	if (f > 4) {
		printf("true\n");
	} else {
		printf("false\n");
	}
}

WMSX Screen (2).png

新しいビットマップ イメージ.png

3
1
6

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?