ElBlo

Compound Literals

Since c99 you can use Compound Literals, which let you define inline objecs like struct, primitive types and arrays easily:

  int i = ++(int) {1};
  memcpy(&foo, &(uint32_t[]){3}, sizeof(uint32_t));

Note that compound literals are not part of the C++ language, and the behavior is different. In C++ they are considered temporary objects and as such, you cannot take their address.

© Marco Vanotti 2024

Powered by Hugo & new.css.