GCC主要数据结构之TTYPE_TABLE

本文详细介绍了C预处理器(cpplib)中各种操作符的定义及其分类,包括比较操作符、数学运算符、位操作符、逻辑操作符等,并解释了它们在预处理器表达式中的作用及其实现方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

cpplib.h

/* The first three groups, apart from '=', can appear in preprocessor    expressions (+= and -= are used to indicate unary + and - resp.).    This allows a lookup table to be implemented in _cpp_parse_expr.

   The first group, to CPP_LAST_EQ, can be immediately followed by an    '='.  The lexer needs operators ending in '=', like ">>=", to be in    the same order as their counterparts without the '=', like ">>".

   See the cpp_operator table optab in expr.c if you change the order or    add or remove anything in the first group.  */

#define TTYPE_TABLE       \   OP(EQ,  "=")      \   OP(NOT,  "!")      \   OP(GREATER,  ">") /* compare */    \   OP(LESS,  "<")      \   OP(PLUS,  "+") /* math */    \   OP(MINUS,  "-")      \   OP(MULT,  "*")      \   OP(DIV,  "/")      \   OP(MOD,  "%")      \   OP(AND,  "&") /* bit ops */    \   OP(OR,  "|")      \   OP(XOR,  "^")      \   OP(RSHIFT,  ">>")      \   OP(LSHIFT,  "<<")      \          \   OP(COMPL,  "~")      \   OP(AND_AND,  "&&") /* logical */    \   OP(OR_OR,  "||")      \   OP(QUERY,  "?")      \   OP(COLON,  ":")      \   OP(COMMA,  ",") /* grouping */    \   OP(OPEN_PAREN, "(")      \   OP(CLOSE_PAREN, ")")      \   TK(EOF,  NONE)      \   OP(EQ_EQ,  "==") /* compare */    \   OP(NOT_EQ,  "!=")      \   OP(GREATER_EQ, ">=")      \   OP(LESS_EQ,  "<=")      \          \   /* These two are unary + / - in preprocessor expressions.  */  \   OP(PLUS_EQ,  "+=") /* math */    \   OP(MINUS_EQ,  "-=")      \          \   OP(MULT_EQ,  "*=")      \   OP(DIV_EQ,  "/=")      \   OP(MOD_EQ,  "%=")      \   OP(AND_EQ,  "&=") /* bit ops */    \   OP(OR_EQ,  "|=")      \   OP(XOR_EQ,  "^=")      \   OP(RSHIFT_EQ,  ">>=")      \   OP(LSHIFT_EQ,  "<<=")      \   /* Digraphs together, beginning with CPP_FIRST_DIGRAPH.  */  \   OP(HASH,  "#") /* digraphs */    \   OP(PASTE,  "##")      \   OP(OPEN_SQUARE, "[")      \   OP(CLOSE_SQUARE, "]")      \   OP(OPEN_BRACE, "{")      \   OP(CLOSE_BRACE, "}")      \   /* The remainder of the punctuation. Order is not significant.  */ \   OP(SEMICOLON,  ";") /* structure */    \   OP(ELLIPSIS,  "...")      \   OP(PLUS_PLUS,  "++") /* increment */    \   OP(MINUS_MINUS, "--")      \   OP(DEREF,  "->") /* accessors */    \   OP(DOT,  ".")      \   OP(SCOPE,  "::")      \   OP(DEREF_STAR, "->*")      \   OP(DOT_STAR,  ".*")      \   OP(ATSIGN,  "@")  /* used in Objective-C */   \          \   TK(NAME,  IDENT)  /* word */    \   TK(AT_NAME,  IDENT)  /* @word - Objective-C */  \   TK(NUMBER,  LITERAL) /* 34_be+ta  */   \          \   TK(CHAR,  LITERAL) /* 'char' */    \   TK(WCHAR,  LITERAL) /* L'char' */    \   TK(CHAR16,  LITERAL) /* u'char' */    \   TK(CHAR32,  LITERAL) /* U'char' */    \   TK(UTF8CHAR,  LITERAL) /* u8'char' */    \   TK(OTHER,  LITERAL) /* stray punctuation */  \          \   TK(STRING,  LITERAL) /* "string" */    \   TK(WSTRING,  LITERAL) /* L"string" */   \   TK(STRING16,  LITERAL) /* u"string" */   \   TK(STRING32,  LITERAL) /* U"string" */   \   TK(UTF8STRING, LITERAL) /* u8"string" */   \   TK(OBJC_STRING, LITERAL) /* @"string" - Objective-C */  \   TK(HEADER_NAME, LITERAL) /* <stdio.h> in #include */  \          \   TK(CHAR_USERDEF, LITERAL) /* 'char'_suffix - C++-0x */  \   TK(WCHAR_USERDEF, LITERAL) /* L'char'_suffix - C++-0x */  \   TK(CHAR16_USERDEF, LITERAL) /* u'char'_suffix - C++-0x */  \   TK(CHAR32_USERDEF, LITERAL) /* U'char'_suffix - C++-0x */  \   TK(UTF8CHAR_USERDEF, LITERAL) /* u8'char'_suffix - C++-0x */  \   TK(STRING_USERDEF, LITERAL) /* "string"_suffix - C++-0x */  \   TK(WSTRING_USERDEF, LITERAL) /* L"string"_suffix - C++-0x */ \   TK(STRING16_USERDEF, LITERAL) /* u"string"_suffix - C++-0x */ \   TK(STRING32_USERDEF, LITERAL) /* U"string"_suffix - C++-0x */ \   TK(UTF8STRING_USERDEF,LITERAL) /* u8"string"_suffix - C++-0x */ \          \   TK(COMMENT,  LITERAL) /* Only if output comments.  */ \      /* SPELL_LITERAL happens to DTRT.  */ \   TK(MACRO_ARG,  NONE)  /* Macro argument.  */   \   TK(PRAGMA,  NONE)  /* Only for deferred pragmas.  */ \   TK(PRAGMA_EOL, NONE)  /* End-of-line for deferred pragmas.  */ \   TK(PADDING,  NONE)  /* Whitespace for -E. */

 
qwe123@qwe123-virtual-machine:~/CLionProjects/C_code/FCH$ gcc -O3 fch_hash.c -lcmph -o fch_hash fch_hash.c: In function ‘build_mphf’: fch_hash.c:59:56: warning: passing argument 1 of ‘cmph_io_vector_adapter’ from incompatible pointer type [-Wincompatible-pointer-types] 59 | cmph_io_adapter_t* source = cmph_io_vector_adapter(dists, 3 * sizeof(uint32_t), 3 * sizeof(uint32_t), num_features); | ^~~~~ | | | uint32_t * {aka unsigned int *} In file included from fch_hash.c:4: /usr/local/include/cmph.h:34:51: note: expected ‘char **’ but argument is of type ‘uint32_t *’ {aka ‘unsigned int *’} 34 | cmph_io_adapter_t *cmph_io_vector_adapter(char ** vector, cmph_uint32 nkeys); | ~~~~~~~~^~~~~~ fch_hash.c:59:33: error: too many arguments to function ‘cmph_io_vector_adapter’ 59 | cmph_io_adapter_t* source = cmph_io_vector_adapter(dists, 3 * sizeof(uint32_t), 3 * sizeof(uint32_t), num_features); | ^~~~~~~~~~~~~~~~~~~~~~ In file included from fch_hash.c:4: /usr/local/include/cmph.h:34:20: note: declared here 34 | cmph_io_adapter_t *cmph_io_vector_adapter(char ** vector, cmph_uint32 nkeys); | ^~~~~~~~~~~~~~~~~~~~~~ fch_hash.c: In function ‘build_hash_table’: fch_hash.c:84:42: warning: passing argument 2 of ‘cmph_search’ from incompatible pointer type [-Wincompatible-pointer-types] 84 | uint32_t idx = cmph_search(mphf, key, 12); | ^~~ | | | uint32_t * {aka unsigned int *} In file included from fch_hash.c:4: /usr/local/include/cmph.h:71:51: note: expected ‘const char *’ but argument is of type ‘uint32_t *’ {aka ‘unsigned int *’} 71 | cmph_uint32 cmph_search(cmph_t *mphf, const char *key, cmph_uint32 keylen); | ~~~~~~~~~~~~^~~ fch_hash.c: In function ‘query_feature’: fch_hash.c:100:38: warning: passing argument 2 of ‘cmph_search’ from incompatible pointer type [-Wincompatible-pointer-types] 100 | uint32_t idx = cmph_search(mphf, key, 12); | ^~~ | | | uint32_t * {aka unsigned int *} In file included from fch_hash.c:4: /usr/local/include/cmph.h:71:51: note: expected ‘const char *’ but argument is of type ‘uint32_t *’ {aka ‘unsigned int *’} 71 | cmph_uint32 cmph_search(cmph_t *mphf, const char *key, cmph_uint32 keylen); | ~~~~~~~~~~~~^~~ fch_hash.c: In function ‘load_hash_table’: fch_hash.c:126:5: warning: ignoring return value of ‘fread’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 126 | fread(table, sizeof(HashTableEntry), size, file); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
最新发布
08-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值