The Tips of Hidden Structure Pointer in Macro Definition in C Language

1. Hiding pointer passing through macro definition

definition:

#define vector_push_back(v, e)  _vector_push_back(v, (void *)&e, sizeof(e))

 void _vector_push_back(struct vector *v, void *e, size_t type_size)

use: 

struct tmp_box tb;

tb.c = 'a';

vector_push_back(c, tb);

You can see that the structure object is directly passed when using it, and there is no need to pass the pointer of the structure. Convenient!

Guess you like

Origin blog.csdn.net/star871016/article/details/109237310