zl程序教程

您现在的位置是:首页 >  后端

当前栏目

C语言中用宏来作注释

C语言 注释 中用
2023-09-11 14:20:28 时间

看了PostgreSQL的代码后,我觉得有不理解的地方,比如:

例如这样的:

/* Options that may appear after CATALOG (on the same line) */
#define BKI_BOOTSTRAP
#define BKI_SHARED_RELATION
#define BKI_WITHOUT_OIDS
#define BKI_ROWTYPE_OID(oid)
#define BKI_SCHEMA_MACRO
CATALOG(pg_tablespace,1213) BKI_SHARED_RELATION
{
    NameData    spcname;        /* tablespace name */
    Oid            spcowner;        /* owner of tablespace */
    text        spclocation;    /* physical location (VAR LENGTH) */
    aclitem        spcacl[1];        /* access permissions (VAR LENGTH) */
    text        spcoptions[1];    /* per-tablespace options */
} FormData_pg_tablespace;

我怀疑它就是个注释的作用。所以我也实验了一把:

[pgsql@localhost tst]$ cat gao01.c
#include <stdio.h>
#include <stdlib.h>

#define MAN
#define WOMAN

int main(){

 typedef struct MAN
 {
    int m_id;
    int m_age;
 } Human_A;

 typedef struct WOMAN
 {
   int m_id;
   int m_age;
 } Human_B;

 typedef Human_A *Human_A_ptr;
 typedef Human_B *Human_B_ptr;

 Human_A_ptr gao01;
 Human_B_ptr gao02;

 gao01= (Human_A_ptr) malloc( sizeof(Human_A));
 gao01->m_id=1;
 gao01->m_age=25;

 free(gao01);

 gao02 = (Human_B_ptr) malloc(sizeof(Human_B));
 gao02->m_id=2;
 gao02->m_age=20;

 free(gao02);

 return 0;

}
[pgsql@localhost tst]$