Copyright © 1999 Seong-Kook Cin
ÀÌ ¹®¼´Â GCC Version 2.7.2¸¦ ±âÁØÀ¸·Î ÇÏ¿© ÀÌ ÄÄÆÄÀÏ·¯°¡ Ãâ·ÂÇÏ´Â
¿¡·¯ [error]¿Í °æ°í [warning] ¸Þ½ÃÁö¸¦ Çѱ¹¾î·Î ¹ø¿ªÇϰí, ±× ¸Þ½ÃÁö¸¦
¹ß»ýÇÒ ¼ö ÀÖ´Â °£´ÜÇÑ ¿¹Á¦¸¦ º¸À̸ç, °£´ÜÇÑ ÇØ°áÃ¥À» Á¦½ÃÇÕ´Ï´Ù.
ÀÌ ¹®¼´Â C ¹è¿ì¹ÌµéÀÌ ³¸¼± ÄÄÆÄÀÏ·¯ ¸Þ½ÃÁö¸¦ ¸¸³µÀ» ¶§ ´çȲÇÏÁö ¾Ê°í ½±°Ô ¹®Á¦¸¦ ÇØ°áÇÒ ¼ö Àֱ⸦ ¹Ù¶ó´Â ¶æ¿¡¼ ¸¸µé¾îÁø °ÍÀÔ´Ï´Ù.
ÀÌ ¹®¼´Â À¯¿ëÇÏ°Ô ¾²¿©Áö±â¸¦ ¹Ù¶ó¸é¼ ¸¸µé¾îÁ³Áö¸¸ ÀúÀÚ´Â ÀÌ ¹®¼¿¡ ´ëÇØ ¾î¶°ÇÑ º¸Áõµµ ÇÏÁö ¾Ê½À´Ï´Ù. Áï, ÀÌ ¹®¼¿¡ ÀÇÇØ ÀϾ ¼ö ÀÖ´Â ¼ÕÇØ¿¡ ´ëÇØ¼´Â Ã¥ÀÓÀ» ÁöÁö ¾Ê½À´Ï´Ù.
ÀÌ ¹®¼´Â GCC°¡ ¹ß»ýÇÒ ¼ö ÀÖ´Â ¿¡·¯ ¸Þ½ÃÁö¸¦ ¸ðµÎ Æ÷ÇÔÇÏÁö ¾ÊÀ» ¼öµµ
ÀÖ½À´Ï´Ù. ¿©·¯ºÐÀÌ ÀÌ ¹®¼¿¡ ¾ø´Â ¿¡·¯ ¸Þ½ÃÁö¸¦ ¹ß°ßÇØ¼, ÀÌ ¹®¼¿¡
Ãß°¡Çϱ⸦ ¿øÇϰųª, ÀÌ ¹®¼¿¡ Ʋ¸° °÷À» ¼öÁ¤Çϱ⸦ ¿øÇÑ´Ù¸é
cinsk@acm.org
À¸·Î
e-mailÀ» º¸³»½Ã±â
¹Ù¶ø´Ï´Ù. ¾î¶°ÇÑ Á¦¾ÈÀ̳ª ºñÆÇµµ ȯ¿µÇÕ´Ï´Ù. ÀúÀÚ´Â ¿©·¯ºÐµéÀÇ Âü¿©·Î ÀÌ ¹®¼°¡
º¸´Ù ¿ÏÀüÇØÁö±â¸¦ ¿øÇÕ´Ï´Ù.
¿¡·¯ ¸Þ½ÃÁö ¼³¸í......................
ÀÌ ¿¡·¯ ¸Þ½ÃÁö¸¦ ¹ß»ý½ÃŰ´Â ¿¹Á¦
ÆÄÀÏ:ÁÙ ¹øÈ£: ½ÇÁ¦ ÄÄÆÄÀÏ·¯°¡ ¹ß»ýÇÏ´Â ¿¡·¯ ¸Þ½ÃÁö
ÁÖ¾îÁø ¹è¿ÀÌ °¡Áú ¼ö ÀÖ´Â ¹®ÀÚÀÇ °³¼öº¸´Ù ¸¹Àº ÃʱⰪÀÌ ÁÖ¾îÁø °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù. C ¾ð¾îÀÇ ¹®ÀÚ¿Àº Å« µû¿ÈÇ¥(`"')·Î µÑ·¯½Î¼ ³ªÅ¸³»¸ç ¹®ÀÚ¿ÀÇ ³¡À» ³ªÅ¸³»±â À§ÇØ ASCII ÄÚµå 0¹ø ¹®ÀÚ(`\0')¸¦ »ç¿ëÇÕ´Ï´Ù. µû¶ó¼ ¾Æ·¡ÀÇ ¿¹¿¡¼ ¹è¿ `ca'´Â Å©±â°¡ 5·Î µÇ¾î ÀÖ¾î¾ß ÇÕ´Ï´Ù.
¹®ÀÚ¿ ¹è¿À» ¾µ ¶§¸¶´Ù ÀÌ·± ½ÄÀ¸·Î
¹è¿ÀÇ Å©±â¸¦ ÁöÁ¤ÇØ ÁÖ´Â °ÍÀº ¹ø°Å·Î¿î ÀÏÀÔ´Ï´Ù. ¹è¿ÀÌ ÃʱⰪÀ»
°¡Áö°í ÀÖÀ» ¶§¿¡´Â ¹è¿ÀÇ Å©±â¸¦ ÁöÁ¤ÇÏÁö ¾Ê¾Æµµ(`ca[]') ÁÁ½À´Ï´Ù.
char ca[3] = "abcd";
file:1: warning: initializer-string for array of chars is too long
¶óÀÎ [line] ¹øÈ£ Á¤º¸¸¦ À߸ø ÀÔ·ÂÇÑ °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù. ¶óÀÎ ¹øÈ£´Â 0º¸´Ù Å« ¾ç¼ö [positive number]À̾î¾ß ÇÕ´Ï´Ù.
invalid format `#line' directive ¿¡·¯¸¦ Âü°íÇϽñâ
¹Ù¶ø´Ï´Ù.
# 0 "foo.c"
file:1: invalid #-line
¶Ç´Â,
#line 0
file:1: invalid #-line
ÀÌ ¿¡·¯°¡ ¹ß»ýÇÏ´Â Á¶°ÇÀº ³Ê¹«³ªµµ ¸¹½À´Ï´Ù. ÀϹÝÀûÀ¸·Î ¹®ÀåÀ» ºÐ¼® [parse]ÇÒ ¶§ ¿¹»óÇÏÁö ¸øÇÑ ±¸¹®À» ¹ß°ßÇßÀ» °æ¿ì¿¡ ÀÌ ¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù. parse error ¿¡·¯¸¦ Âü°íÇϱ⠹ٶø´Ï´Ù.
Á¶°Ç 1: typedef·Î Á¤ÀÇÇÑ Çü¿¡ short, long, signed, unsigned µîÀ» »ç¿ëÇÒ ¶§.
typedef int INT;
unsigned INT ui;
file:2: parse error before `ui'
file:2: warning: data definition has no type or storage class
Á¶°Ç 2:
void f()
{
else {
}
}
file: In function `f':
file:3: parse error before `else'
»ç¿ëÀÚ°¡ Á¤ÀÇÇÑ ¸ÅÅ©·Î¸¦ ´Ù½Ã Á¤ÀÇÇϰųª, ANSI C ȤÀº ÄÄÆÄÀÏ·¯°¡ ¹Ì¸®
Á¤ÀÇÇØ ³õÀº ¸ÅÅ©·Î¸¦ Àç Á¤ÀÇÇÏ·Á ÇÒ ¶§ ¹ß»ýÇÕ´Ï´Ù. »ç¿ëÀÚ°¡ Á¤ÀÇÇÑ ¸ÅÅ©·ÎÀÎ
°æ¿ì, #undef Áö½Ã¾î¸¦ ½á¼ ÀÌ °æ°í¸¦ ¾ø¾Ù ¼ö ÀÖ½À´Ï´Ù.
#define MY_CONST "cinsk"
#define MY_CONST "windy"
file:2: warning: `MY_CONST' redefined
ANSI C ȤÀº ÄÄÆÄÀÏ·¯°¡ ¹Ì¸® Á¤ÀÇÇØ ³õÀº ¸ÅÅ©·Î(predefined macro)¸¦
¾ø¾Ù °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù.
ÀÌ °æ°í°¡ ¹ß»ýÇÒ °æ¿ì, ¿©·¯ºÐÀº ´Ù¸¥ ¸ÅÅ©·Î¸¦ ½á¾ß ÇÕ´Ï´Ù. ¹Ì¸® Á¤ÀÇµÈ ¸ÅÅ©·Î¸¦
´Ù¸¥ ¸ñÀûÀ¸·Î ¾²´Â °ÍÀº ÁÁÁö ¾Ê½À´Ï´Ù. ANSI C ȤÀº ÄÄÆÄÀÏ·¯°¡ ¹Ì¸® Á¤ÀÇÇØ ³õÀº
»ó¼ö ¸ñ·ÏÀº ÄÄÆÄÀÏ·¯¿Í ÇÔ²² Á¦°øµÇ´Â ¸Å´º¾óÀ» Âü°íÇϽñ⠹ٶø´Ï´Ù.
#undef __FILE__
file1: warning: undefining `__FILE__'
ANSI C´Â Çϳª ÀÌ»óÀÇ °¡º¯ ÀÎÀÚ [variable length argument]¸¦ ¹ÞÀ» ¼ö ÀÖ°Ô
ÇÏÁö¸¸ Çϳª ÀÌ»óÀÇ °íÁ¤µÈ ÀÎÀÚ°¡ ÀÖ¾î¾ß ÇÕ´Ï´Ù. ¾Æ·¡ÀÇ ¿¹¿¡¼ ÇÔ¼ö f()´Â °íÁ¤µÈ
ÀÎÀÚ°¡ Çϳªµµ ¾ø±â ¶§¹®¿¡ ÀÌ ¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù.
void f(...) { }
file:1: ANSI C requires a named argument before `...'
ÁÖ¾îÁø ¸ÅÅ©·ÎÀÇ ÀÎÀÚ¸¦ ÀÐÀ» ¶§ °ýÈ£°¡ ´ÝÈ÷Áö ¾ÊÀ» °æ¿ì
ÀÌ ¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù.
#define NOP(x)
NOP(foo
file:2: unterminated macro call
¸ÅÅ©·Î¸¦ Á¤ÀÇÇÒ ¶§ °°Àº À̸§À» µÎ ÀÎÀÚ¿¡ ´ëÇØ ½èÀ» °æ¿ì ÀÌ
¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù.
#define ADD3(a, a, c) ((a) + (b) + (c))
file:1: duplicate argument name `a' in `#define'
¾î±¸ ºÐ¼®(parsing)¿¡ ½ÇÆÐÇßÀ» °æ¿ì ÀÌ ¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù. ÀÌ ¿¡·¯°¡ ¹ß»ýÇÏ´Â °æ¿ì´Â ¸Å¿ì ¸¹½À´Ï´Ù. parse error before `XXX' ¿¡·¯¸¦ Âü°íÇϱ⠹ٶø´Ï´Ù.
Á¶°Ç 1: `#elif' ´ÙÀ½¿¡ »ó¼ö½ÄÀÌ ¿ÀÁö ¾ÊÀ» ¶§
#if defined(ONE)
int i = 1;
#elif
int i = 2;
#endif
file3: parse error
Á¶°Ç 2: ºñ¾îÀÖ´Â ¸ÅÅ©·Î¸¦ À߸ø ½èÀ» ¶§.
#define EMPTY
#if EMPTY
char *msg = "EMPTY is non-empty";
#endif
file:2: parse error
ºó ¹®ÀÚ »ó¼ö°¡ ¾²¿´À» ¶§ ÀÌ ¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù.
int i = '';
file:1: empty character constant
`#include' directive¿¡¼ ÆÄÀÏ À̸§ÀÌ ÁÖ¾îÁöÁö ¾Ê¾ÒÀ» ¶§ ¹ß»ýÇÕ´Ï´Ù.
#include <>
file:1: empty file name in `#include'
`#endif' directive°¡ if ¼½¼Ç ('#if', `#ifdef', `#ifndef' µîÀ¸·Î ½ÃÀÛÇÏ´Â)
°ú ¸Â°Ô ¾²ÀÌÁö ¾ÊÀ» ¶§ ¹ß»ýÇÕ´Ï´Ù.
#endif
file:1: unbalanced `#endif'
int f(int i)
{
enum e { l, j, k, i};
}
file: In function `f':
file:3: warning: declaration of `i' shadows a parameter
file:4: warning: control reaches end of non-void function
Á¤¼ö·Î Ãë±ÞµÇ´Â ½Ä (enumerator Æ÷ÇÔ)¿¡¼ ¿À¹öÇ÷οì(overflow)°¡
ÀϾ °æ¿ì¿¡ ÀÌ °æ°í°¡ ¹ß»ýÇÕ´Ï´Ù.
#include
ÀÌ ¿¡·¯´Â ÄÄÆÄÀÏ·¯¿¡°Ô ¼Ò½º°¡ Àü´ÞµÇ±â Àü, ÇÁ¸®ÇÁ·Î¼¼¼(preprocessor)¿¡ ÀÇÇØ ¹ß»ýÇÕ´Ï´Ù. ÇÁ¸®ÇÁ·Î¼¼¼´Â `#error'·Î ½ÃÀÛÇÏ´Â ¹®ÀåÀ» ¸¸³ª¸é ¹Ù·Î ÄÄÆÄÀÏ ÀÛ¾÷À» Áß´ÜÇϰí `#error' ¹®ÀåÀ» Ãâ·ÂÇÕ´Ï´Ù. ÀÌ´Â ´ë°³ ÇÁ·Î±×·¥ ¼Ò½º°¡ Ưº°ÇÑ È¯°æÀ» ¿ä±¸ÇÏ´Â °æ¿ì, ÀûÇÕÇÏÁö ¾ÊÀº ȯ°æÀÏ ¶§¿¡´Â ÄÄÆÄÀÏÀÌ µÇÁö ¾Ê°Ô Çϱâ À§ÇÑ ¸ñÀûÀ¸·Î ¾²ÀÔ´Ï´Ù.
ANSI C¿¡¼´Â ¸î °³ÀÇ ¹Ì¸® Á¤ÀǵÈ(predefined) »ó¼ö¸¦ Á¤ÀÇÇϰí ÀÖ°í, ÄÄÆÄÀÏ·¯¿¡
µû¶ó¼ Ãß°¡ÀûÀÎ »ó¼ö¸¦ Á¦°øÇÕ´Ï´Ù. `#error'ÀÇ °æ¿ì, ÀÌµé »ó¼ö¿Í °°ÀÌ ¾²ÀÌ´Â
°æ¿ì°¡ ÀϹÝÀûÀ̹ǷÎ, ÀÚ¼¼ÇÑ °ÍÀº ÄÄÆÄÀÏ·¯ÀÇ ¸Å´º¾óÀ» Âü°íÇϽñ⠹ٶø´Ï´Ù.
#ifndef NEVER_DEFINED
#error NEVER_DEFINED required
#endif
file:2: #error NEVER_DEFINED required
int f(int)
{
return 0;
}
file:1: parameter name omitted
int f(void)[];
file:1: `f' declared as function returning an array
void f(void)
{
char *p;
p();
}
file: In function `f':
file:4: called object is not a function
int f(void)
{
return;
}
file: In function `f':
file:3: warning: `return' with no value, in function returning non-void
file
¹®ÀÚ »ó¼ö°¡ `''·Î ´ÝÈ÷Áö ¾ÊÀ» °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù.
char ch = 'a;
file:1: unterminated character constant
ÁÖ¼® [comment]ÀÌ `/*'·Î ´ÝÈ÷Áö ¾ÊÀ» °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù.
/* This is a comment
file:1: unterminated comment
¹®ÀÚ »ó¼ö³ª ¹®ÀÚ¿ÀÌ `"'·Î ³¡³ªÁö ¾ÊÀ» °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù.
char *str = "cinsk\
the wind
file:1: unterminated string or character constant
file:2: possible real start of unterminated constant
¹®ÀÚ »ó¼ö³ª ¹®ÀÚ¿ÀÌ `"'·Î ³¡³ªÁö ¾ÊÀ» °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù.
char *str = "hello\
world
file:1: unterminated string or character constant
file:2: possible real start of unterminated constant
ÇÔ¼öÀÇ ¸®ÅÏ Çü [return type]À» »ý·«ÇÒ °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù.
¸®ÅÏ ÇüÀÌ »ý·«µÈ ÇÔ¼öÀÇ ¸®ÅÏ ÇüÀº `int'ÀÔ´Ï´Ù.
foo(void)
{
return 0;
}
file:2: warning: return-type defaults to `int'
ÇÔ¼öÀÇ ¸®ÅÏ Çü [return type]ÀÌ `void'°¡ ¾Æ´Ñµ¥µµ ÇÔ¼ö°¡ `return' ¹®À»
°¡ÁöÁö ¾ÊÀ» °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù. ÀÌ °æ¿ì ÇÔ¼ö¸¦ `void' ÇüÀ¸·Î ¼±¾ðÇϰųª
`return' ¹®À» ¾²¸é ÇØ°áµË´Ï´Ù.
int foo(void) {}
file:1: warning: control reaches end of non-void function
void Çü Æ÷ÀÎÅÍ [pointer]´Â ´Ù¸¥ Çü Æ÷ÀÎÅͷΠij½ºÆ® [cast]Çϱâ Àü¿¡´Â
¾µ ¼ö ¾ø½À´Ï´Ù. Áï, ÀÌ ¿¡·¯´Â void Çü Æ÷ÀÎÅÍ¿¡ ¿ªÂüÁ¶ [dereference] ¿¬»êÀÚÀÎ
`*'¸¦ ½è±â ¶§¹®¿¡ ¹ß»ýÇÕ´Ï´Ù. ÀÌ ¿¡·¯¸¦ ÇØ°áÇÏ·Á¸é void Çü Æ÷ÀÎÅ͸¦ ´Ù¸¥ Çü
Æ÷ÀÎÅÍ (¿¹¸¦ µé¾î `int *')·Î ij½ºÆÃ [casting]ÇØ¼ ¾²¸é µË´Ï´Ù.
void foo(void)
{
void *p, *q;
*(p = q);
}
file:4: warning: dereferencing `void *' pointer
file:4: warning: value computed is not used
Á¤ÀǵÇÁö ¾ÊÀº ÇüÀ» °¡¸®Å°´Â Æ÷ÀÎÅÍ [pointer]¿¡ ¿ªÂüÁ¶ [dereference]
¿¬»êÀÚ(`*')¸¦ ¾µ ¼ö ¾ø½À´Ï´Ù.
struct s;
void g(struct s *);
void f(void)
{
struct s *p;
g(*p);
}
file:6: dereferencing pointer to incomplete type
ÇÔ¼ö XXXÀÇ N¹øÂ° ÆÄ¶ó¸ÞÅÍ [parameter]°¡ Á¤¼öÇüÀε¥µµ ij½ºÆÃ [casting]¾øÀÌ
Æ÷ÀÎÅ͸¦ ÀÎÀÚ [argument]·Î ¾´ °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù.
void f(int);
void g(void)
{
f("erroneous");
}
file:4: warning: passing arg 1 of `f' makes integer from pointer without a cast
int f(char *);
void g()
{
f(5);
}
file: In function `g':
file:4: warning: passing arg 1 of `f' makes pointer from integer without a cast
ÇÔ¼ö ¼±¾ð¿¡ ¾²ÀÎ ÆÄ¶ó¸ÞÅÍ [parameter]ÀÇ Çü°ú ½ÇÁ¦ ÀÎÀÚ [argument]ÀÇ
ÇüÀÌ ¼·Î ´Þ¶ó¼ º¯°æÇÒ ¼ö ¾ø´Â °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù.
struct s { int a; } p;
void f(void)
{
void g(int, int);
g(5, p);
}
file:5: incompatible type for argument 2 of `g'
ÇÔ¼ö ¼±¾ð¿¡ ¾²ÀÎ ÆÄ¶ó¸ÞÅÍ [parameter]ÀÇ ¼öº¸´Ù ½ÇÁ¦ ÀÎÀÚ [argument]ÀÇ
°³¼ö°¡ ÀûÀ» °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù.
void f(void)
{
void g(int, int);
g(5);
}
file:4: too few arguments to function `g'
ÇÔ¼ö ¼±¾ð¿¡ ¾²ÀÎ ÆÄ¶ó¸ÞÅÍ [parameter]ÀÇ ¼öº¸´Ù ½ÇÁ¦ ÀÎÀÚ [argument]ÀÇ
°³¼ö°¡ ¸¹À» °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù.
void f(void)
{
void g(int);
g(5, 2);
}
file:4: too many arguments to function `g'
´ëÀÔ [assignment] ¿¬»ê¿¡¼ ¿¬»êÀÚ `=' »çÀÌÀÇ ¿ÀÆÛ·£µå [operand]ÀÇ ÇüÀÌ
¼·Î ¿ÏÀüÈ÷ ´Ù¸¨´Ï´Ù. assignment makes integer from
pointer without a cast °æ°í¸¦ Âü°íÇϽñ⠹ٶø´Ï´Ù.
struct s {};
void f()
{
struct s st;
int i;
i = st;
}
file:7: incompatible types in assignment
´ëÀÔ [assignment] ¿¬»ê¿¡¼ ¿¬»êÀÚ `=' ¾çÂÊ¿¡ ¿À´Â ¿ÀÆÛ·£µå [operand]°¡
¿ÞÂÊÀº Á¤¼öÇü, ¿À¸¥ÂÊÀº Æ÷ÀÎÅÍÀÏ °æ¿ì¿¡ ÀÌ °æ°í°¡ ¹ß»ýÇÕ´Ï´Ù.
À̸¦ ÇØ°áÇÏ·Á¸é Æ÷ÀÎÅ͸¦ Á¤¼öÇüÀ¸·Î ij½ºÆÃ [casting]ÇØ¾ß ÇÕ´Ï´Ù.
incompatible types in assignment ¿¡·¯¸¦ Âü°íÇϽñ⠹ٶø´Ï´Ù.
void f()
{
char *cp;
int i;
i = cp;
}
file:5: warning: assignment makes integer from pointer without a cast
ÇÔ¼ö ¹Ù±ù¿¡ ¼±¾ðµÈ ¼±¾ð¿¡ `auto' Ű¿öµå°¡ ¾²¿´½À´Ï´Ù. `auto' Ű¿öµå´Â
ÀÚµ¿ º¯¼ö [automatic variable]¸¦ ¼±¾ðÇϱâ À§ÇØ ¾²´Â °ÍÀ̹ǷΠÀü¿ª º¯¼ö
[global variable]¿¡ ¾²ÀÏ ¼ö ¾ø½À´Ï´Ù.
auto int i;
file:1: top-level declaration of `i' specifies `auto'
`register' Ű¿öµå´Â ÀÚÁÖ ¾²ÀÌ´Â º¯¼ö¸¦ ¸Þ¸ð¸® ´ë½Å (°¡´ÉÇÏ´Ù¸é [if possible])
CPUÀÇ ·¹Áö½ºÅÍ [register]¸¦ ¾²µµ·Ï ÇÕ´Ï´Ù. Àü¿ª º¯¼ö [global variable]¿¡´Â
`register' Ű¿öµå¸¦ ¾µ ¼ö ¾ø½À´Ï´Ù.
register int i;
file:1: register name not specified for `i'
°°Àº ½ºÄÚÇÁ [scope] ¾È¿¡ °°Àº À̸§ÀÌ ¾²ÀÎ °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù. ´Ù¸¥ º¯¼ö
À̸§À» ½á¾ß ÇÒ °ÍÀÔ´Ï´Ù. ÀÌ ¿¡·¯´Â
`XXX' previously declared here ¿¡·¯¿Í ÇÔ²² ¹ß»ýÇÕ´Ï´Ù.
void foo()
{
int i;
int i;
i = 3;
}
file:4: redeclaration of `i'
file:3: `i' previously declared here
°°Àº ½ºÄÚÇÁ [scope] ¾È¿¡ °°Àº À̸§ÀÌ ¾²ÀÎ °æ¿ì¿¡ óÀ½ ¼±¾ðÇÑ °÷À»
³ªÅ¸³» ÁÝ´Ï´Ù. ÀÌ ¿¡·¯´Â
redeclaration of `XXX'
¿¡·¯¿Í ÇÔ²² ¹ß»ýÇÕ´Ï´Ù.
void foo()
{
int i;
int i;
i = 3;
}
file:4: redeclaration of `i'
file:3: `i' previously declared here
`#include'¿¡ ¾²ÀÌ´Â ÆÄÀÏ À̸§Àº `"'³ª `<>'·Î µÑ·¯½Î¾ß ÇÕ´Ï´Ù.
#include stdio.h
file:1: `#include' expects "FILENAME" or <FILENAME>
ÁÖ¾îÁø ¼öÄ¡ »ó¼ö [numeric constant]°¡ Áø¹ý¿¡ ¸ÂÁö ¾ÊÀ» °æ¿ì¿¡
¹ß»ýÇÕ´Ï´Ù. ¿¹¸¦ µé¾î 8 Áø¼ö¿¡¼ ¾²ÀÏ ¼ö ÀÖ´Â ¼ýÀÚ´Â 0, 1, ..., 7Àε¥
¾Æ·¡ÀÇ ¿¹Ã³·³ 8À» ¾´´Ù°Å³ª, 16 Áø¼ö¿¡¼ ¾²ÀÏ ¼ö ÀÖ´Â ¹®ÀÚ´Â a, b, ..., fÀε¥
f ÀÌÈÄÀÇ ¹®ÀÚ¸¦ ¾µ °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù.
int i = 08;
int j = 0xah;
file:1: numeric constant contains digits beyond the radix
file:2: numeric constant contains digits beyond the radix
`#' ¸ÅÅ©·Î ¿¬»êÀÚ´Â ¸ÅÅ©·Î ÀÎÀÚ [argument] ¾Õ¿¡ ³ª¿Í ÀÌ ÀÌ ÀÎÀÚ¸¦
¹®ÀÚ¿ [string]·Î ¸¸µé¾îÁÖ´Â ¿ªÇÒÀ» ÇÕ´Ï´Ù. `#' ¿¬»êÀÚ°¡ ¸ÅÅ©·Î À̸§
¾Õ¿¡ ³ª¿ÀÁö ¾ÊÀº °æ¿ì¿¡ ÀÌ ¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù.
#define bug(s) s #
file:1: `#' operator is not followed by a macro argument name
`##' ¸ÅÅ©·Î ¿¬»êÀÚ´Â µÎ °³ÀÇ ÀÎÀÚ [argument]¸¦ ¹Þ¾Æ À̵éÀ»
ÇϳªÀÇ ÅäÅ« [token]À¸·Î ¹Ù²Ù¾î ÁÝ´Ï´Ù. µû¶ó¼ `##' ¿¬»êÀÚ´Â `+' ¿¬»êÀÚó·³
¾²ÀÌ¸ç ¾çÂÊ¿¡ ÀÎÀÚ°¡ ¿Í¾ß ÇÕ´Ï´Ù. `##' ¿¬»êÀÚ ¾Õ¿¡ ÀÎÀÚ°¡ ¿ÀÁö ¾ÊÀ» ¶§
ÀÌ ¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù.
#define bug(s) ## s
file:1: `##' at start of macro definition
`##' ¸ÅÅ©·Î ¿¬»êÀÚ´Â µÎ °³ÀÇ ÀÎÀÚ [argument]¸¦ ¹Þ¾Æ À̵éÀ»
ÇϳªÀÇ ÅäÅ« [token]À¸·Î ¹Ù²Ù¾î ÁÝ´Ï´Ù. µû¶ó¼ `##' ¿¬»êÀÚ´Â `+' ¿¬»êÀÚó·³
¾²ÀÌ¸ç ¾çÂÊ¿¡ ÀÎÀÚ°¡ ¿Í¾ß ÇÕ´Ï´Ù. `##' ¿¬»êÀÚ µÚ¿¡ ÀÎÀÚ°¡ ¿ÀÁö ¾ÊÀ» ¶§
ÀÌ ¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù.
#define bug(s) s ##
file:1: `##' at end of macro definition
structÀ̳ª union, enumÀ» ½á¼ ÇÑ ÇüÀ» ¸¸µé¶§, ÀÌ ¶§ »ç¿ëÇÑ tag (¿¹¸¦
µé¾î struct s;¿¡¼ tag´Â `s'°¡ µË´Ï´Ù.)°¡ ´Ù¸¥ ŸÀÔ¿¡¼ ¾²ÀÏ ¶§ ÀÌ ¿¡·¯°¡
¹ß»ýÇÕ´Ï´Ù.
struct s { int x, y, z; };
void f()
{
union s foo;
foo.x = 1;
}
file:4: `s' defined as wrong kind of tag
bit field¿¡¼ bit °¹¼ö¸¦ ÁöÁ¤ÇÒ ¶§ À½¼ö [negative number]³ª 0À»
¾µ ¼ö ¾ø½À´Ï´Ù.
struct s { int x : -3; };
file:1: negative width in bit-field `x'
Bit fieldÀÇ Å©±â°¡ ÁÖ¾îÁø ÇüÀÇ Å©±â¸¦ ³ÑÀ» °æ¿ì ¹ß»ýÇÕ´Ï´Ù. Å©±â°¡
Å« ´Ù¸¥ ÇüÀ¸·Î ¹Ù²Ù°Å³ª bit fieldÀÇ Å©±â¸¦ ÁÙ¿© ÇØ°áÇÒ ¼ö ÀÖ½À´Ï´Ù.
struct s { char c : 20; };
file:1: warning: width of `c' exceeds its type
`break' Ű¿öµå´Â switch, while, do-while, for ³»ºÎ¿¡¼¸¸ ¾²ÀÏ ¼ö
ÀÖ½À´Ï´Ù. `break'¸¦ ´Ù¸¥ °÷¿¡¼ ¾µ °æ¿ì ÀÌ ¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù.
void f()
{
break;
}
file:3: break statement not within loop or switch
`.' ¿¬»êÀÚ´Â ±¸Á¶Ã¼ [structure]³ª union¿¡¼ ¸â¹ö [member]¸¦ ¿¢¼¼½ºÇϱâ
À§ÇØ »ç¿ëÇϸç, ±¸Á¶Ã¼³ª unionÀÌ ¾Æ´Ñ °÷¿¡¼ `.'¸¦ »ç¿ëÇÒ °æ¿ì¿¡ ÀÌ ¿¡·¯°¡
¹ß»ýÇÕ´Ï´Ù. ´ë°³ÀÇ °æ¿ì, ±¸Á¶Ã¼ÀÇ À̸§À» Ʋ¸®°Ô ½èÀ» °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù.
struct s { int i; };
void f()
{
char c;
c.i = 3;
}
file:5: request for member `i' in something not a structure or union
C ¾ð¾î´Â ¿©·¯ ³ª¶óÀÇ ¾ð¾î¸¦ Áö¿øÇϱâ À§ÇØ multibyte ¹®ÀÚÀÎ wide character¸¦
Áö¿øÇÕ´Ï´Ù. Wide character »ó¼ö´Â ¹®ÀÚ »ó¼ö³ª ¹®ÀÚ¿ ¾Õ¿¡ 'L'À» ºÙ¿© ³ªÅ¸³»¸ç
ÀÌ ÇüÀº wchar_t (<stddef.h>¿¡ Á¤ÀǵǾî ÀÖ½À´Ï´Ù) ÀÔ´Ï´Ù. ÀÌ ¿¡·¯´Â wchar_t Çü
¹®ÀÚ¿À» char Çü ¹è¿¿¡ ÃʱⰪÀ¸·Î ¾µ ¶§ ¹ß»ýÇÕ´Ï´Ù. ¹è¿À» wchar_t ÇüÀ¸·Î
¼±¾ðÇϰųª ÃʱⰪÀ» char Çü »ó¼ö¸¦ ½á¼ ÀÌ ¿¡·¯¸¦ ÇØ°áÇÒ ¼ö ÀÖ½À´Ï´Ù.
char a[] = L"abc";
file:1: char-array initialized from wide string
void ÇüÀº Æ÷ÀÎÅÍ ÇüÀ¸·Î ¾²°Å³ª ÇÔ¼öÀÇ return °ªÀ¸·Î ¾²ÀÌ´Â °æ¿ì¿¡¸¸
Àǹ̰¡ ÀÖ½À´Ï´Ù. ´Ù¸¥ °æ¿ì, ¿¹¸¦ µé¾î void Çü ¹è¿À» ¼±¾ðÇÏ´Â °ÍÀº ¿ÇÁö
¾Ê½À´Ï´Ù.
void a[3];
file:1: declaration of `a' as array of voids
ÇÁ¸®ÇÁ·Î¼¼¼ [preprocessor]ÀÇ ¿¬»êÀÚÀÎ `defined'´Â ¸ÅÅ©·Î À̸§À¸·Î Á¤ÀÇµÉ ¼ö ¾øÀ¸¸ç, Á¤ÀǸ¦ Ãë¼ÒÇÒ ¼öµµ ¾ø½À´Ï´Ù.
invalid macro name `XXX' ¿¡·¯¸¦ Âü°íÇϽñ⠹ٶø´Ï´Ù.
#undef defined
#define defined abc
file:1: invalid macro name `defined'
file:2: invalid macro name `defined'
#undef 4
file:1: invalid macro name `4'
´ÜÇ× ¿¬»êÀÚ [unary operator] `*'´Â Æ÷ÀÎÅÍ ¾Õ¿¡¼ ÀÌ Æ÷ÀÎÅͰ¡ °¡¸®Å°´Â
°ÍÀ» ¿ªÂüÁ¶ [dereference]Çϱâ À§ÇØ ¾²ÀÔ´Ï´Ù. `*' ¿¬»êÀÚ°¡ Æ÷ÀÎÅͰ¡ ¾Æ´Ñ
´Ù¸¥ Çü¿¡ ¾²À̸é ÀÌ ¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù.
void f()
{
int i;
*i = 3;
}
file:4: invalid type argument of `unary *'
¾ÆÁ÷ ¿ÏÀüÇÏ°Ô Á¤Àǰ¡ ¾Ë·ÁÁöÁö ¾ÊÀº Çü¿¡ ´ëÇØ¼ Æ÷ÀÎÅÍ ¿¬»êÀ» ¼öÇàÇÒ
¼ö ¾ø½À´Ï´Ù. ¾Æ·¡ÀÇ ¿¹¿¡¼ ÀÌ ¿¡·¯°¡ ¹ß»ýÇÏÁö ¾Ê°Ô ÇÏ·Á¸é ¸ÕÀú `struct s'
ÇüÀÇ Á¤ÀǸ¦ ³»·Á¾ß ÇÕ´Ï´Ù.
struct s;
void g(struct s*);
void f()
{
struct s *p;
g(p + 1);
}
file:6: arithmetic on pointer to an incomplete type
`#include'¿¡¼ ¾´ ÆÄÀÏÀ» ãÀ» ¼ö ¾øÀ» ¶§ ÀÌ ¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù. ´ë°³ ÀÌ
¿¡·¯´Â »ç¿ëÀÚ°¡ ¸¸µç ÆÄÀÏÀ» `"' ´ë½Å `<>'·Î µÑ·¯½Î°Å³ª ÆÄÀÏ À̸§À» Ʋ¸®°Ô
ÀÔ·ÂÇϰųª, ¶Ç´Â ÄÄÆÄÀÏ·¯ ¿É¼Ç¿¡¼ µð·ºÅ丮 ¼³Á¤ÀÌ À߸øµÇ¾î ÀÖ´Â °æ¿ì,
ÄÄÆÄÀÏ·¯¿¡¼ ¾²À̴ ȯ°æ º¯¼ö [environment variable]°¡ À߸ø ÁöÁ¤µÇ¾î ÀÖ´Â
°æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù. ÀÚ¼¼ÇÑ °ÍÀº GCC ¹®¼(info)¿¡¼ `-I' ¿É¼ÇÀ̳ª `C_INCLUDE_PATH'
ȯ°æ º¯¼ö¸¦ Âü°íÇϽñ⠹ٶø´Ï´Ù.
#include <where_is_it.h>
file:1: where_is_it.h: No such file or directory
º¯¼ö³ª field´Â void ÇüÀ¸·Î ¼±¾ðÇÒ ¼ö ¾ø½À´Ï´Ù.
ÀúÀÚ°¡ ¾²°í ÀÖ´Â GCC 2.7.2´Â Àü¿ª º¯¼ö [global variable]·Î
`void a;'¸¦ ¼±¾ðÇϸé ÀÌ ¿¡·¯¸¦ ¸¸µéÁö ¾Ê½À´Ï´Ù. ÀÌ´Â ¹ö±×ÀÎ °ÍÀ¸·Î
»ý°¢µÇ´Âµ¥, ÀÌ ¹®Á¦¿¡ ´ëÇØ µµ¿òÀ» ÁÖ½Ç ¼ö ÀÖ´Â ºÐÀº ¾Ë·Á Áֽøé
°¨»çÇϰڽÀ´Ï´Ù. ¿¬¶ôó´Â ÀÌ ¹®¼ÀÇ Ã³À½¿¡ ÀÖ½À´Ï´Ù.
void foo()
{
void a;
}
file:3: variable or field `a' declared void
file:4: warning: unused variable `a'
ÇÔ¼öÀÇ ³»ºÎ¿¡¼ `extern'À¸·Î ¼±¾ðµÈ ¿ÀºêÁ§Æ® [object]´Â
ÃʱⰪ [initializer]À» °¡Áú ¼ö ¾ø½À´Ï´Ù.
`XXX' initialized and declared `extern'
°æ°í¸¦ Âü°íÇϽñ⠹ٶø´Ï´Ù.
extern int i = 1;
void f()
{
extern int j = 3;
}
file:1: warning: `i' initialized and declared `extern'
file: In function `f':
file:4: `j' has both `extern' and initializer
tmp.c:4: warning: unused variable `i'
`extern'À¸·Î ¼±¾ðµÈ ¿ÀºêÁ§Æ® [object]¿¡ ÃʱⰪ [initializer]À» ÁÖ¸é
`extern'Àº ¹«½ÃµË´Ï´Ù.
`XXX' has both `extern' and initializer
¿¡·¯¸¦ Âü°íÇϽñ⠹ٶø´Ï´Ù.
extern int i = 1;
void f()
{
extern int j = 3;
}
file:1: warning: `i' initialized and declared `extern'
file: In function `f':
file:4: `j' has both `extern' and initializer
tmp.c:4: warning: unused variable `i'
ÇÔ¼ö·Î ¼±¾ð [declaration]µÈ À̸§Àº ÃʱⰪ [initializer]À»
°¡Áú ¼ö ¾ø½À´Ï´Ù.
int f(void) = 3;
file:1: function `f' is initialized like a variable
¿¹Àü ¹æ½Ä [old style]À¸·Î ¼±¾ðµÈ ÇÔ¼ö¿¡¼ ÆÄ¶ó¸ÞÅÍ [parameter]´Â
ÃʱⰪ [initializer]À» °¡Áú ¼ö ¾ø½À´Ï´Ù.
void f(i)
int i = 3;
{
}
file:2: parameter `i' is initialized
`typedef'´Â ±âÁ¸ÀÇ Çü¿¡ ´ëÇØ »õ Çü À̸§ [type name]À» Á¤ÀÇÇÏ´Â °ÍÀ̱â
¶§¹®¿¡ ÃʱⰪ [initializer]À» °¡Áú ¼ö ¾ø½À´Ï´Ù.
typedef int INT = 1;
file:1: typedef `INT' is initialized
ÄÄÆÄÀÏ·¯°¡ ÁÖ¾îÁø ÆÄÀÏ À̸§ (µð·ºÅ丮 Æ÷ÇÔ)À» ãÀ» ¼ö ¾øÀ» ¶§ ¹ß»ýÇÕ´Ï´Ù.
´ë°³ ÆÄÀÏ À̸§À» Ʋ¸®°Ô ÀÔ·ÂÇßÀ» ¶§ ¹ß»ýÇÕ´Ï´Ù.
gcc where_is_it.c
where_is_it.c: No such file or directory
¸ÅÅ©·Î³ª `#include'°¡ Àç±ÍÀûÀ¸·Î ³Ê¹« ±í°Ô ¹Ýº¹µÉ ¶§ ¹ß»ýÇÕ´Ï´Ù.
¿¹¸¦ µé¾î `util.h'°¡ `types.h'¸¦ Æ÷ÇÔ (#include)Çϰí, `types.h'°¡ ´Ù½Ã
`util.h'¸¦ Æ÷ÇÔÇÏ´Â °æ¿ì, ÀÌµé ÆÄÀÏÀ» ¼Ò½º¿¡ Æ÷ÇÔ½Ã۸é, ¼·Î°¡ ¼·Î¸¦
°è¼Ó Æ÷ÇÔ½ÃŰ°Ô µÇ¹Ç·Î °á±¹ ÄÄÆÄÀÏ·¯´Â ÀÌ ¿¡·¯¸¦ ¹ß»ý½Ãŵ´Ï´Ù.
ÀÌ·² ¶§¿¡´Â `#ifndef', `#define', `#endif' µîÀ» ½á¼ Àç±ÍÀûÀ¸·Î
Æ÷ÇÔµÇÁö ¾Ê°Ô ÇØ¼ ÇØ°áÇÕ´Ï´Ù.
#include "util.h"
file:1: macro or `#include' recursion too deep
ÁÖ¾îÁø ÇüÀÌ ¿ÏÀüÈ÷ Á¤ÀǵÇÁö ¾ÊÀº »óÅ¿¡¼ ÀÌ ÇüÀ» »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.
¾Æ·¡ÀÇ ¿¹¿¡¼´Â ÇÔ¼ö g()ÀÇ return ÇüÀÌ `struct s'ÀÌÁö¸¸ `struct s'´Â ¾ÆÁ÷
Á¤ÀǵÇÁö ¾Ê¾Ò½À´Ï´Ù. ÀÌ ¶§ g()¸¦ ºÎ¸£´Â °ÍÀº ¿ÇÁö ¾Ê½À´Ï´Ù. ÀÌ ¹®Á¦¸¦
ÇØ°áÇÏ·Á¸é ÇÔ¼ö g()¸¦ ºÎ¸£±â Àü¿¡ ¸ÕÀú `struct s'¸¦ Á¤ÀÇÇØ¾ß ÇÕ´Ï´Ù.
void f()
{
struct s g();
g();
}
file:4: invalid use of undefined type `struct s'
Bit field¿¡´Â `address of' ¿¬»êÀÚÀÎ `&'¸¦ ¾µ ¼ö ¾ø½À´Ï´Ù.
struct s { int i : 3; };
void f()
{
struct s p;
int *ip = &p.i;
}
file:5: attempt to take address of bit-field structure member `i'
file:5: warning: unused variable `ip'
`register'·Î ¼±¾ð [declaration]µÈ º¯¼ö¿¡ `address of' ¿¬»êÀÚ¸¦ ¾µ °æ¿ì¿¡
¹ß»ýÇÕ´Ï´Ù. `register'¸¦ ¾´´Ù°í Ç×»ó CPUÀÇ ·¹Áö½ºÅÍ¿¡ ÀÌ º¯¼ö°¡ ÀúÀåµÇ´Â °ÍÀº
¾Æ´ÏÁö¸¸, ½ÇÁ¦ CPU ·¹Áö½ºÅÍÀÇ »ç¿ë ¿©ºÎ¿¡ »ó°ü¾øÀÌ `register'¸¦ ¾´ º¯¼öÀÇ
ÁÖ¼Ò¸¦ ¾ò´Â °ÍÀº ¿ÇÁö ¾Ê½À´Ï´Ù.
void f()
{
register int i;
int *ip = &i;
ip = 0;
}
file:4: warning: address of register variable `i' requested
Bit-field¿¡´Â `sizeof' ¿¬»êÀÚ¸¦ ¾µ ¼ö ¾ø½À´Ï´Ù.
struct s { int i : 3; };
void f()
{
struct s p;
int i = sizeof(p.i);
i = 3;
}
file:5: `sizeof' applied to a bit-field
`case'¿¡¼ ¾´ »ó¼ö½Ä [constant expression]Àº `switch'¿¡¼ ¾´ µ¥ÀÌÅÍ ÇüÀÇ
¹üÀ§¸¦ ³ÑÀ» ¼ö ¾ø½À´Ï´Ù. ¾Æ·¡ÀÇ ¿¹¿¡¼´Â `case'ÀÇ »ó¼ö½Ä
0xffffff
°¡ `char' ÇüÀÇ ¹üÀ§¸¦ ³Ñ¾ú±â ¶§¹®¿¡ ¹ß»ýÇÕ´Ï´Ù.
ÀÌ ¹®Á¦¸¦ ÇØ°áÇÏ·Á¸é `switch'¿¡¼ ¾´ µ¥ÀÌÅÍÀÇ ÇüÀ» Á» ´õ Å« Çü
(¿¹¸¦ µé¾î `int')À¸·Î ¹Ù²Ù¾î¾ß ÇÕ´Ï´Ù.
void f()
{
char c;
switch (c) {
case 0xffffff:
;
}
}
file:5: warning: case value out of range
`case'´Â `switch' ±¸Á¶ ¾È¿¡¼¸¸ ¾µ ¼ö ÀÖ½À´Ï´Ù.
void f()
{
case 4:
;
}
file:3: case label not within a switch statement
Á¤¼ö¾È¿¡ µé¾î°¡±â¿¡´Â ³Ê¹« ¸¹Àº ¹®ÀÚ¸¦ °¡Áö°í ÀÖ´Â »ó¼ö¸¦ ¾µ ¶§¿¡
ÀÌ ¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù.
int i = 'abcde';
file:1: character constant too long
¹®ÀÚ »ó¼ö³ª ¹®ÀÚ¿¿¡ ¾²ÀÎ escape sequence°¡ ³Ê¹« Å« °ªÀ» °¡Áö°í ÀÖ¾î
¹®ÀÚ [unsigned char]·Î Ç¥ÇöÇÒ ¼ö ¾øÀ» ¶§ ÀÌ °æ°í°¡ ¹ß»ýÇÕ´Ï´Ù. ÀÌ·¯ÇÑ °ªµéÀº
ÀûÀýÇÏ°Ô Àß¶ó³» [truncate] ¹ö¸³´Ï´Ù.
char *p = "\x1ff\400";
file:1: warning: escape sequence out of range for character
file:1: warning: escape sequence out of range for character
`continue' Ű¿öµå´Â ·çÇÁ [loop] (for, while, do-while) ¾È¿¡¼¸¸
Àǹ̰¡ ÀÖ½À´Ï´Ù. `continue'¸¦ ·çÇÁ ¹Û¿¡¼ ¾²´Â °ÍÀº ¿ÇÁö ¾Ê½À´Ï´Ù.
void foo()
{
continue;
}
file:3: continue statement not within a loop
X´Â ¹ÙÀ̳ʸ® ¿¬»êÀÚ (¿¹: +, -, *, /, ==, !=, <=, >= µî)À̸ç, ¿¬»êÀÚÀÇ ¿ÀÆÛ·£µå ÇüÀº ½ºÄ®¶ó [scalar] ÇüÀ̾î¾ß ÇÕ´Ï´Ù. Áï Á¤¼ö³ª ½Ç¼öÀ̾î¾ß Çϸç, ±¸Á¶Ã¼ [structure]³ª union ÇüÀÌ ¿Ã ¼ö ¾ø½À´Ï´Ù.
ÀÌ ¿¡·¯´Â Á¶°Ç½Ä [conditional expression]ÀÌ ÇÊ¿äÇÑ if, for, while, do-while µî¿¡¼ ±¸Á¶Ã¼³ª unionÇüÀ» ¾µ ¶§¿¡µµ ¹ß»ýÇÕ´Ï´Ù.
¶Ç ÀÌ ¿¡·¯´Â ÇüÀÌ ´Ù¸¥ Æ÷ÀÎÅÍ¿¡ ¿¬»êÀ» ÃëÇÒ ¶§¿¡µµ ¹ß»ýÇÒ ¼ö ÀÖ½À´Ï´Ù.
struct s { int i; };
void f()
{
struct s p;
int i = (p != 0);
while (p) {
}
}
file: In function `f':
file:5: invalid operands to binary !=
file:7: invalid operands to binary !=
file:5: warning: unused variable `i'
void f()
{
char *cp;
int *ip;
int i;
i = ip - cp;
}
file: In function `f':
file:6: invalid operands to binary -
ÀÌ ¿¡·¯´Â Á¶°Ç½ÄÀÎ `? :'À» ¾µ ¶§¿¡µµ ¹ß»ýÇÕ´Ï´Ù. Á¶°Ç½Ä `e1 ? e2 : e3'´Â
`e1'ÀÌ ÂüÀÏ °æ¿ì, `e2'°¡ Æò°¡µÇ°í, °ÅÁþÀÏ ¶§¿¡´Â `e3'°¡ Æò°¡µË´Ï´Ù. ÀÌ ¶§
ÀÌ Á¶°Ç½ÄÀº `if (e1 != 0) e2 else e3'·Î Ãë±ÞµÇ¹Ç·Î ¸¸¾à `e1'ÀÌ ½ºÄ®¶ó ÇüÀÌ
¾Æ´Ï¸é ÀÌ ¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù.
struct s { int x; } st;
void f(void)
{
int i = st ? 3 : 4;
}
file: In function `f':
file:5: invalid operands to binary !=
file:5: warning: unused variable `i'
ÁÖ¾îÁø »ó¼ö¸¦ ÇÔÃàÀûÀ¸·Î [implicitly] º¯È¯ [conversion]ÇÒ ¶§
¿À¹öÇ÷οì [overflow]°¡ ¹ß»ýÇÒ ¶§ ÀÌ °æ°í°¡ ¹ß»ýÇÕ´Ï´Ù. ¾Æ·¡ÀÇ ¿¹´Â
`int' ÇüÀÇ ¹üÀ§¸¦ ³Ñ´Â ½Ç¼ö »ó¼ö (double Çü)¸¦ `int' Çü¿¡ ´ëÀÔÇÏ·Á ÇÏ´Â
°æ¿ì¸¦ ³ªÅ¸³À´Ï´Ù.
int i = 1e300;
file:1: warning: overflow in implicit constant conversion
ÇÔ¼ö ³»ºÎ¿¡¼ ÀÌ ÇÔ¼ö¿¡ Àü´ÞµÇ´Â ÆÄ¶ó¸ÞÅÍ [parameter]¿Í °°Àº À̸§À»
¼±¾ðÇÑ °æ¿ì¿¡ ¹ß»ýÇÕ´Ï´Ù. Áï ÆÄ¶ó¸ÞÅÍÀÇ À̸§ÀÌ »õ ¼±¾ð [declaration]¿¡
ÀÇÇØ °¡·ÁÁ³À¸¹Ç·Î ÀÌ ¼±¾ðÀÌ ³ª¿Â ´ÙÀ½ºÎÅÍ´Â ÀÌ À̸§À» °¡Áø ÆÄ¶ó¸ÞÅ͸¦
¾µ ¼ö ¾ø½À´Ï´Ù. ÀÌ °æ¿ì, µÑ Áß Çϳª¸¦ ´Ù¸¥ À̸§À» °®°Ô °íÄ¡´Â °ÍÀÌ
ÁÁ½À´Ï´Ù.
void f(int i, int INT)
{
int i;
i = 3;
}
file:3: warning: declaration of `i' shadows a parameter
µ¥ÀÌÅÍ (ÇÔ¼ö³ª º¯¼öµî)¸¦ Á¤ÀÇÇÒ ¶§ ÇüÀ» ¾²Áö ¾ÊÀ» °æ¿ì ¹ß»ýÇÕ´Ï´Ù.
ÀϹÝÀûÀ¸·Î ÇÔ¼ö³ª º¯¼öÀÇ return ÇüÀ» ¾²Áö ¾ÊÀ» ¶§ ¹ß»ýÇϸç, ÀÌ ¶§¿¡´Â
`int' ÇüÀ¸·Î °£Áֵ˴ϴÙ.
i;
f();
file:1: warning: data definition has no type or storage class
file:2: warning: data definition has no type or storage class
`default' Ű¿öµå´Â `switch' ¹® [statement] ¾È¿¡¼¸¸ ¾µ ¼ö ÀÖ½À´Ï´Ù.
void f()
{
default:
;
}
file:3: default label not within a switch statement
¸ÅÅ©·Î À̸§Àº À¯È¿ÇÑ [valid] C ¾ð¾î À̸§ [identifier]ÀÌ ³ª¿Í¾ß ÇÕ´Ï´Ù. Áï ù±ÛÀÚ´Â [_a-zA-Z]À̸ç, µÎ¹øÂ° ±ÛÀÚºÎÅÍ´Â [_a-zA-Z0-9]ÀÔ´Ï´Ù. ¾Æ·¡ÀÇ ¿¹¿¡¼ `3'Àº À̸§ [identifier]ÀÌ µÉ ¼ö ¾ø±â ¶§¹®¿¡ ÀÌ ¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù.
invalid macro name `defined' ¿¡·¯µµ Âü°íÇϽñ⠹ٶø´Ï´Ù.
#define 3
file:1: invalid macro name `3'
`#line' Áö½Ã¾î [directive] µÚ¿¡´Â ¶óÀÎ ¹øÈ£¸¦ ÀǹÌÇÏ´Â ¼öÄ¡°¡ ³ª¿Í¾ß ÇÕ´Ï´Ù. ÀÌ ¼öÄ¡´Â 0ÀÌ ¾Æ´Ñ ¾ç¼ö [positive number]À̾î¾ß ÇÕ´Ï´Ù.
invalid #-line ¿¡·¯¸¦ Âü°íÇϽñ⠹ٶø´Ï´Ù.
#line 02a
file:1: invalid format `#line' directive
¹®ÀÚ¿¿¡¼ `\' µÚ¿¡ ¿À´Â ¹®Àڴ ƯÁ¤ÇÑ ¶æÀÌ ÀÖ´Â ¸î °³ÀÇ ¹®ÀÚ¸¸ ¾µ ¼ö
ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¾î `\n'Àº newline ¹®ÀÚ¸¦ ³ªÅ¸³»°í, `\t'´Â tab ¹®ÀÚ¸¦
³ªÅ¸³À´Ï´Ù. À̸¦ `escape sequence'¶ó°í Çϸç, ¾Ë·ÁÁöÁö ¾ÊÀº ¹®ÀÚ°¡ `escape
sequence'·Î ¾²ÀÎ °æ¿ì ÀÌ °æ°í°¡ ¹ß»ýÇÕ´Ï´Ù. ÀÌ ¶§ ¾²ÀÎ `\x'´Â ÀÏ¹Ý ¹®ÀÚ `x'·Î
Ãë±ÞµË´Ï´Ù.
int i = '\q';
file:1: warning: unknown escape sequence `\q'
µÎ `case' ¹®Àå¿¡¼ °°Àº »ó¼ö °ªÀÌ ¾²¿´À» ¶§ ¹ß»ýÇÕ´Ï´Ù.
void f()
{
int a = 3;
switch (a) {
case 1:
case 1:
default:
break;
}
}
file: In function `f':
file:6: duplicate case value
file:5: this is the first entry for that value
`switch' ¹®Àå ¾È¿¡¼ `default' ·¹À̺íÀÌ µÎ °³ ÀÌ»ó ¾²¿´À» °æ¿ì ¹ß»ýÇÕ´Ï´Ù.
void f()
{
int a = 3;
switch (a) {
case 1:
default:
default:
break;
}
}
file: In function `f':
file:7: multiple default labels in one switch
file:6: this is the first default label
`struct'À̳ª `union'¿¡¼ °°Àº À̸§ÀÌ µÎ °³ ÀÌ»óÀÇ ¸â¹ö¿¡ ¾²¿´À» ¶§ ÀÌ ¿¡·¯°¡
¹ß»ýÇÕ´Ï´Ù. °¢°¢ ´Ù¸¥ À̸§À» ½á¼ ÀÌ ¿¡·¯¸¦ ¾ø¾Ù ¼ö ÀÖ½À´Ï´Ù.
struct s {
int i;
float i;
};
file:3: duplicate member `i'
¼±ÅÃÀû ÄÄÆÄÀÏÀ» ÇÒ ¼ö ÀÖ´Â `preprocessor directive'ÀÎ `#if', `#elif',
`#else', `#endif'¿¡¼ `#elif'´Â Ç×»ó `#else' ¾Õ¿¡ ³ª¿Í¾ß ÇÕ´Ï´Ù.
#if defined(ONE)
int i = 1;
#elif defined(TWO)
int i = 2;
#else
int i = 3;
#elif defined(FOUR)
int i = 4;
#endif
file:7: `#elif' after `#else'
(matches line 1)
`Preprocessor directive'ÀÎ `#else'³ª `#elif'´Â `#if'³ª `#ifdef', `#ifndef'
µîÀÇ if ¼½¼ÇÀÇ ÀϺηΠ¾²¿©Á®¾ß ÇÕ´Ï´Ù. `#elif'°¡ ´Üµ¶À¸·Î ¾²¿´À» °æ¿ì ÀÌ ¿¡·¯°¡
¹ß»ýÇÕ´Ï´Ù.
#elif defined(TWO)
int i = 2;
#endif
file:1: `#elif' not within a conditional
file:3: unbalanced `#endif'
#else
int i = 2;
#endif
file:1: `#else' not within a conditional
file:3: unbalanced `#endif'
`struct'À̳ª `union'ÀÇ ÃʱⰪÀ» Áß°ýÈ£({})·Î ½ÎÁö ¾Ê´Â µî, À߸øµÈ ÃʱⰪÀ»
½èÀ» ¶§ ÀÌ ¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù.
struct s {
int x;
int y;
} st = 1;
file:4: invalid initializer
Enumerator·Î ¾²ÀÏ ¼ö ÀÖ´Â »ó¼ö´Â ¹Ýµå½Ã Á¤¼öÇü °ªÀ» °¡Á®¾ß ÇÕ´Ï´Ù.
½Ç¼ö(real)³ª ´Ù¸¥ »ó¼ö°¡ ¾Æ´Ñ °ªÀÌ ¾²À̸é ÀÌ ¿¡·¯°¡ ¹ß»ýÇÕ´Ï´Ù.
enum A { AA = 0.1, BB = 2 };
file:1: enumerator value for `AA' not integer constant
ÇÔ¼öÀÇ ¼±¾ðÀº ANSI ¹æ½Ä°ú ¿¾ ¹æ½Ä Áß Çϳª¸¦ ¾µ ¼ö ÀÖ½À´Ï´Ù. ¿¾ ¹æ½ÄÀº ÇÔ¼öÀÇ ÀÎÀÚ ¸®½ºÆ®¸¦ ¾²Áö ¾Ê°í, ANSI ¹æ½ÄÀº ÀÎÀÚÀÇ Å¸ÀÔ°ú °¹¼ö¸¦ ²À ÁöÁ¤ÇØ¾ß ÇÕ´Ï´Ù. ¾Æ·¡ÀÇ ¿¹¿¡¼´Â ÇÔ¼ö fÀÇ ÀÎÀÚÀÎ `i'ÀÇ Å¸ÀÔÀ» ÁöÁ¤ÇÏÁö ¾Ê¾Ò±â ¶§¹®¿¡ ÀÌ °æ°í°¡ ¹ß»ýÇÑ °ÍÀÔ´Ï´Ù.
int f(i); file:1: warning: parameter names (without types) in function declaration
#abc
file:1: undefined or invalid # directive
# 0x12
file:1: invalid preprocessing directive name
int i;
long i;
file:2: conflicting types for `i'
file:1: previous declaration of `i'
int i = 0;
int i = 1;
file:2: redefinition of `i'
file:1: `i' previously defined here
#if
int i = 2;
#endif
file:1: empty #if expression
#ifdef A
int i = 1;
file:1: unterminated `#if' conditional
#ifdef
int i = 1;
#endif
file:1: warning: `#ifndef' with no argument
#ifndef
int i = 1;
#endif
void f()
{
g();
}
file:3: warning: implicit declaration of function `g'
int f()
{
void g();
int i = (int)g();
return i;
}
file: In function `f':
file:5: void value not ignored as it ought to be
struct abc {
int a, b;
};
void f()
{
struct abc a;
a.c = 0;
}
cf. unionµµ °°À½
file: In function `f':
file:8: structure has no member named `c'
int i = "abc";
file:1: warning: initialization makes integer from pointer without a cast
#define max(a
file:1: badly punctuated parameter list in `#define'
struct s st;
file:1: storage size of `st' isn't known
file:
file:
file:
file: