Search notes:

C: _Generic

Determine the type of an expression at runtime.
#define getType(x) _Generic ( (x) ,   \
   int    : "int"                 ,   \
   char   : "char"                ,   \
   char*  : "pointer to a char"   ,   \
   float  : "float"               ,   \
   double : "double"              ,   \
   void*  : "pointer to anything" ,   \
   default: "?"                       \
)

#define printType(x) printf("The type of %-15s is: %s\n", #x, getType(x))

#include <stdio.h>

int main () {
  printType (42);
  printType (42.42);
  printType (42.42f);
  printType ("Hello World");
  printType (NULL);
}
Github repository about-c, path: /_Generic.c

See also

C

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758199478, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/C-C-plus-plus/C/_Generic(61): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78