search

Home  >  Q&A  >  body text

c++ - What are the syntax rules for ## in define?

In allocation.hpp of the jdk8 source code, there is

#define METASPACE_OBJ_TYPE_DECLARE(name) name ## Type,
#define METASPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name;

  enum Type {
    // Types are MetaspaceObj::ClassType, MetaspaceObj::SymbolType, etc
    METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_DECLARE)
    _number_of_types
  };

I don’t understand what grammatical rules ## are in define.

大家讲道理大家讲道理2730 days ago769

reply all(2)I'll reply

  • 某草草

    某草草2017-06-05 11:13:07

    #define is to define variables, the two ## are connection operators, you can view

    reply
    0
  • 漂亮男人

    漂亮男人2017-06-05 11:13:07

    ## is the concatenation operator, see https://stackoverflow.com/que...

    reply
    0
  • Cancelreply