简体   繁体   中英

What is Significance of _v(l) in the macro?

I am trying to understand the following macro from the following URL :

do {                                                                    \
  word _v(l) = vec_len (V);                                             \
  V = _vec_resize ((V), 1, (_v(l) + 1) * sizeof ((V)[0]), (H), (A));    \
  (V)[_v(l)] = (E);                                                     \
} while (0)

what is the significance of _v(l)? Is it just a variable or something more?

The _v macro is defined in vec.h at line 207 :

 #define _v(var) _vec_##var

This prepends _vec_ before var . You can observe this by asking your favorite compiler to print the output of the preprocessor stage ( -E flag for clang/gcc and /E for msvc).

#define _v(var) _vec_##var
word _v(l) = vec_len (V);

Is expanded into:

word _vec_l = vec_len (V);

It is a variable whose name is generated. The name probably includes the current line number to make it unique. Therefore using this macro twice in a line may or may not work.

To see what the macro expands to, run gcc -E to only preprocess the code but not compile it. Do a bit of research about this -E computer option, it is helpful in many similar cases as well.

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