[PROC] 매크로의 띄어쓰기 문제 [정정:뛰어쓰기 -> 띄어쓰기]

lovewar의 이미지

proc를 변환하여 c로 만들때 보면 다음과 같은 코드가 눈에 들어옵니다.

이 중 # define SQL_CRSR의 문구의 해석을 부탁드립니다.

/* Result Sets Interface */
#ifndef SQL_CRSR
#  define SQL_CRSR
  struct sql_cursor
  {
    unsigned int curocn;
    void *ptr1;
    void *ptr2;
    unsigned long magic;
  };
  typedef struct sql_cursor sql_cursor;
  typedef struct sql_cursor SQL_CURSOR;
#endif /* SQL_CRSR */
Fe.head의 이미지

lovewar wrote:
proc를 변환하여 c로 만들때 보면 다음과 같은 코드가 눈에 들어옵니다.

이 중 # define SQL_CRSR의 문구의 해석을 부탁드립니다.

/* Result Sets Interface */
#ifndef SQL_CRSR
#  define SQL_CRSR
  struct sql_cursor
  {
    unsigned int curocn;
    void *ptr1;
    void *ptr2;
    unsigned long magic;
  };
  typedef struct sql_cursor sql_cursor;
  typedef struct sql_cursor SQL_CURSOR;
#endif /* SQL_CRSR */

SQL_CRSR 이 선언 되어 있지 않으면
    SQL_CRSR 를 선언한다.
    sql_cursor 구조체를 선언및 재정의한다.

#             define SQL_CRSR

#define  SQL_CRSR

는 동일합니다.

고작 블로킹 하나, 고작 25점 중에 1점, 고작 부활동
"만약 그 순간이 온다면 그때가 네가 배구에 빠지는 순간이야"

정태영의 이미지

lovewar wrote:
proc를 변환하여 c로 만들때 보면 다음과 같은 코드가 눈에 들어옵니다.

이 중 # define SQL_CRSR의 문구의 해석을 부탁드립니다.

/* Result Sets Interface */
#ifndef SQL_CRSR
#  define SQL_CRSR
  struct sql_cursor
  {
    unsigned int curocn;
    void *ptr1;
    void *ptr2;
    unsigned long magic;
  };
  typedef struct sql_cursor sql_cursor;
  typedef struct sql_cursor SQL_CURSOR;
#endif /* SQL_CRSR */

c에서 코드를 작성할 때 if for while 등으로 블록이 새로 시작될 때 들여쓰기를 하듯이 매크로에서도 동일한 행동을 한 것입니다...

오랫동안 꿈을 그리는 사람은 그 꿈을 닮아간다...

http://mytears.org ~(~_~)~
나 한줄기 바람처럼..

lovewar의 이미지

Quote:

c에서 코드를 작성할 때 if for while 등으로 블록이 새로 시작될 때 들여쓰기를 하듯이 매크로에서도 동일한 행동을 한 것입니다...

이러한 동일한 행동이 컴파일마다 동일한 동작을 하나요?

이부분도 조언 부탁드립니다.

-- 덧붙이는 글 --
#define 문이 미치는 영역은 #undef 문을 만날때까지인데
구지 들어쓰기까지 할 필요가 있는지 의문이 듭니다.

amir173의 이미지

The C Preprocessor 참고해보세요[/code]

lifthrasiir의 이미지

lovewar wrote:
Quote:

c에서 코드를 작성할 때 if for while 등으로 블록이 새로 시작될 때 들여쓰기를 하듯이 매크로에서도 동일한 행동을 한 것입니다...

이러한 동일한 행동이 컴파일마다 동일한 동작을 하나요?

이부분도 조언 부탁드립니다.

-- 덧붙이는 글 --
#define 문이 미치는 영역은 #undef 문을 만날때까지인데
구지 들어쓰기까지 할 필요가 있는지 의문이 듭니다.

일단 #과 directive name 사이의 공백은 어떤 다른 역할을 하지 않으므로 무시하셔도 됩니다.

그럼 순전히 취향의 문제인데... 이런 코드라면 들여쓰기를 하는 것도 나쁘지는 않을 것 같습니다. (즉 프리프로세서 구문이 많이 nested되어 있을 경우인데, 이 경우에도 취향에 따라 안 할 사람도 많겠죠)

#ifndef SOMETHING
#  define SOMETHING
#  if __LITTLEENDIAN__
Uint32 swap32_be(Uint32 x) { .... }
#    define swap32_le(x) (x)
#  else
#    define swap32_be(x) (x)
Uint32 swap32_le(Uint32 x) { .... }
#  endif
#endif

- 토끼군

lovewar의 이미지

개인적으로는 아래처럼 라인을 띄어쓰기하는 기법이 좋아 보입니다.

 
#ifndef SQLCA
#define SQLCA 1
 
struct   sqlca
         {
         /* ub1 */ char    sqlcaid[8];
         /* b4  */ int     sqlabc;
         /* b4  */ int     sqlcode;
         struct
           {
           /* ub2 */ unsigned short sqlerrml;
           /* ub1 */ char           sqlerrmc[70];
           } sqlerrm;
         /* ub1 */ char    sqlerrp[8];
         /* b4  */ int     sqlerrd[6];
         /* ub1 */ char    sqlwarn[8];
         /* ub1 */ char    sqlext[8];
         };

#ifndef SQLCA_NONE 
#ifdef   SQLCA_STORAGE_CLASS
SQLCA_STORAGE_CLASS struct sqlca sqlca
#else
         struct sqlca sqlca
#endif
 
#ifdef  SQLCA_INIT
         = {
         {'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '},
         sizeof(struct sqlca),
         0,
         { 0, {0}},
         {'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '},
         {0, 0, 0, 0, 0, 0},
         {0, 0, 0, 0, 0, 0, 0, 0},
         {0, 0, 0, 0, 0, 0, 0, 0}
         }
#endif
         ;
#endif
 
#endif

-- 덧붙이는 글 --

아래 손님께 감사..

익명 사용자의 이미지

죄송합니다만 '뛰어쓰기'가 아니라 '띄어쓰기'입니다. :wink:

tinywolf의 이미지

전 아래와 같은 스타일로 작성하지요..

#ifndef TESTDEFINE
#   define TESTDEFINE(x, y) \
    { \
        if (x == NULL) \
            delete[] y; \
    }
#else
#   undef TESTDEFINE
#endif // TESTDEFINE

뭐 영 엉뚱한 내용이긴 하지만.. 저런식으로..
나중에 코드 보기가 수월합니다..
(매크로를 좋아해서.. ㅎㅎ)

ㅡ_ㅡ;

댓글 달기

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