Yoichi's diary


2010-08-07

_ [sqlite] ESCAPE

'%' 自体は ESCAPE には使えない。ってそりゃそうだな。 $ がよくつかわれるみたい。
hoge%fuga
hoge$fuga
とあれば、それぞれ LIKE 'hoge$%fuga' ESCAPE '$'、LIKE 'hoge$$fuga' ESCAPE '$' でひっかけれる。

2010-08-25

_ [comp/c] warning

/* hoge.c */
#include <stdio.h>
 
int main()
{
	unsigned int i1 = 1;
	long i2 = 2;
	if (i1 - i2 < 0)
	{
		printf("true\n");
	}
	else
	{
		printf("false\n");
	}
	return 0;
}

_ gcc の場合、-Wall に加えて -W を付けると警告が増える

% gcc -Wall hoge.c
% gcc -Wall -W hoge.c
hoge.c: In function `main':
hoge.c:8: warning: comparison of unsigned expression < 0 is always false
% gcc --version
gcc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
えらい古いバージョンだった。
% gcc-4 --version
gcc-4 (GCC) 4.3.2 20080827 (beta) 2
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
% gcc-4 -Wall hoge.c
% gcc-4 -Wall -W hoge.c
hoge.c: In function 'main':
hoge.c:8: warning: comparison of unsigned expression < 0 is always false
こちらは古いと思わないところがあれかも。

_ cl の場合は /Wall を付けると警告が全て有効になる

C:\Users\yoichi\tmp>cl /W4 hoge.c
Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.
 
hoge.c
Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.
 
/out:hoge.exe
hoge.obj
 
C:\Users\yoichi\tmp>cl /Wall hoge.c
Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.
 
hoge.c
C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\stdio.h(381) : warning C4255: '_get_printf_count_output' : 関数プロトタイプがありません : '()' を '(void)' に変換します。
hoge.c(4) : warning C4255: 'main' : 関数プロトタイプがありません : '()' を '(void)' に変換します。
hoge.c(8) : warning C4296: '<' : 式は常に False です。
Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.
 
/out:hoge.exe
hoge.obj