简体   繁体   中英

how to change typedef struct declaration into a using alias struct?

my struct is defined like this:

typedef struct
{
  int foo;
  char key;
} myStruct;

and I would like to change it to

using struct myStruct = {
      int foo;
      char key;
    } myStruct;

but it seems that something is wrong with it

Yes, you can replace

typedef struct
{
  int foo;
  char key;
} myStruct;

by

using myStruct = struct
{
  int foo;
  char key;
};

But it doesn't make any sense, and you will just confuse readers or possible maintainers of the code.

The established way to go is:

struct myStruct
{
  int foo;
  char key;
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM