gcc로 컴파일 하는데.. 구조체 선언에 대해서 질문입니다.

kyin5593의 이미지

//////////////////////////////////////////////////////
//Queue.c

typedef struct _queue Queue;
typedef struct _queue
{
..
..
Queue* queue;
};

int main()
{
..
..
..
return 0;
}
//////////////////////////////////////////////////////

이런식으로 소스를 만들었는데요..
gcc로 컴파일 하니까..

"useless storage class specifier in empty declaration"

이런 에러가 뜨네요..

g++로 컴파일하면 잘 되는데요..
어떻게 고쳐야 하나요??


netionics의 이미지

:)

:)

freestyle의 이미지

typedef struct _point1 POINT1;
struct _point1 {
        int x;
        int y;
};
 
 
typedef struct _point2 {
        int x;
        int y;
} POINT2;
 
 
struct _point3 {
        int x;
        int y;
};
typedef struct _point3 POINT3;
 
 
typedef struct {
        int x;
        int y;
} POINT4;

struct와 typedef를 같이 쓰는 방법을 나열해 봤습니다.
구조체 멤버로 typedef로 지정한 형이 반복적으로 나올 경우에는

첫번째 방법이나 이곳의 방법을 사용하시면 됩니다.

Quote:
Q 2.1
다음 두 선언의 차이점이 무엇인가요?

struct x1 { ... };
typedef struct { ... } x2;

Answer
첫번째 선언은 ``구조체 태그(structure tag)''를 선언한 것입니다; 두번째 선언은 ``typedef''를 선언한 것입니다. 주 차이점은 첫번째 경우의 타입 이름은 struct x1이며, 두번째 경우의 타입 이름은 간단히 x2라는 것입니다. 즉 두번째 것이 조금 더 추상화된 타입이라 할 수 있습니다. -- 즉 사용자들이 struct이라는 키워드를 쓰지 않게되어 이 타입이 구조체인지 아닌지 알 필요가 없습니다:

x2 b;

tag를 써서 정의된 구조체는 다음과 같이 선언해야 합니다.2.1

struct x1 a;

(두 가지 방식 모두 적용해서 다음과 같이 정의할 수도 있습니다:

typedef struct x3 { ... } x3;

조금 혼동스럽기는 하지만, tag 이름과 typedef 이름이 중복되는 것은, 서로 다른 namespace에 속하기 때문에, 전혀 상관없습니다. 질문 [*]1.29를 보기 바랍니다.)


[출처] cinsk님의 CFAQS 번역본
----------------------------------
Go to the U-City

----------------------------------------------------------------------------------------
Don't Feed the Trolls!
----------------------------------------------------------------------------------------

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.