C 어떻게 타입을 정의하죠?

bw001730의 이미지

헤더 파일에 아래와 같은 순서로 데이타타입이 있습니다.

1   struct _a
2   {
3         int             kkk;
4        struct _b    bbb;      
5   }


6   struct _b
7   {
8       int            qqq;
9       struct _a  aaa;
10  }

근데 이렇게 두고 컴파일하면 에러가 발생하드라구요
4번 줄의 데이타타입은 6번줄에 있으니깐..에러가 발생하는것 같은데요
이럴 경우 어떻게 해야하죠?

씨 왕초보입니다. ㅠㅠ

[/code]

익명 사용자의 이미지

Quote:

코드:

1 struct _a
2 {
3 int kkk;
4 struct _b bbb;
5 }

6 struct _b
7 {
8 int qqq;
9 struct _a aaa;
10 }

struct 를 선언할때는

struct struct_name 
{
int property
} varname;

과 같은식으로 해주셔야 합니다. varname 은 생략이 가능하며, ';' 는 빠뜨리면 안됩니다.
pynoos의 이미지

만약 저게 가능하다면, 크기가 무한대이겠지요?

일단, 메타 크기가 존재한다고 가정하고, 메타를 포함한 메타의 크기를 생각하면, 메타의 메타의 메타 크기를 생각해야되고... 아마 지니의 지니의 지니의.. 지니가 대답하다 포기해야할지도 모릅니다.

저런 경우에는 한쪽을 pointer로 합니다.
그리고, 맨 위에..

struct _a;
struct _b;

라고 몇 줄 적어 선언먼저 하면되는 것이죠.

GunSmoke의 이미지

1   struct _a 
2   { 
3         int             kkk; 
4        struct _b    bbb;      
5   } 


6   struct _b 
7   { 
8       int            qqq; 
9       struct _a  aaa; 
10  } 

구조체 안의 멤버로 불완전형은 허락되지 않습니다. 그렇기 때문에 4번째 라인에서 문제가 발생하는 것이며 이를 해결하는 방법은 pynoo님께서 말씀하셨다시피 포인터를 활용합니다.

大逆戰

bw001730의 이미지

답변 감사드립니다.
다른 헤더 파일에도 보니깐 그렇게 되어 있네요..
정말 감사................^______^

댓글 달기

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