gcc의 에러 메세지에 관한 도움말이 있습니까? Man page 말고요

indizarm의 이미지

음... 뭐 모든 컴파일러가 제 취향에 맞는 에러 메세지를

생성하는 것은 아니지만, 에러 메세지들이 너무 낯설어서

'에러 메세지에 관한 도움말'이 있었으면 하는 생각이 들

었습니다.

다음은 간단한 소스와 그에 대한 에러 메세지 입니다.

<tmp_hdr.h>

#if !defined TMP_HDR_H
#define TMP_HDR_H

struct test;
typedef struct test* ptr;
typedef struct test
{
        int i;
        char ch;
        ptr next;
};

#endif


<test.c>

#include<stdio.h>
#include"tmp_hdr.h"


int main()
{
        test jkl;

        jkl.i = 1;
        jkl.ch = 'A';
        return 0;
}


<에러 메세지>

[indizarm@je2 testbed]$ gcc -o test test.c
test.c:6: two or more data types in declaration of `main'
test.c:6: function definition declared `typedef'
test.c: In function `main':
test.c:7: `test' undeclared (first use in this function)
test.c:7: (Each undeclared identifier is reported only once
test.c:7: for each function it appears in.)
test.c:7: parse error before "jkl"
test.c:9: `jkl' undeclared (first use in this function)
김충길의 이미지

typedef struct test
{
int i;
char ch;
ptr next;
};

위에서 typedef 를 빼세요.

test jkl;

에서 struct test jkl; 로 사용하세요.

아니면 typedef struct test { ..blabla } test; 로 하시던지.

screen + vim + ctags 좋아요~

indizarm의 이미지

김충길님 답변 감사합니다.

그런데 nested struct의 경우에 사용할 수 있는

범위가 선언된 블록의 안이 아닙니까?

예:

typedef struct out_first
{
    struct in
    {
        int i;
    }in;

    struct in in_inst;
}out_first;

typedef struct out_second
{
    struct in
    {
        int i;
    }in;
    
    struct in in_inst;
}out_second;

이렇게 하면 struct in redefinition 이라고 에러가

뜨더군요. 제 생각으로는 nested struct의 경우엔

선언된 블록 내에서만 효력이 있을 것으로 생각했습

니다만...

What a Cool Days!!!

purewell의 이미지

GCC Manual...인데 도움이 될지 모르겠습니다.

http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Trouble.html#Trouble

_____________________________
언제나 맑고픈 샘이가...
http://purewell.biz

indizarm의 이미지

purewell님 답변 감사합니다.
^_^

What a Cool Days!!!

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.