For years I have been initializing my struct stat
like this:
#include <sys/stat.h>
struct stat foo = {0};
Specifically, that {0}
set all the fields to zero, equivalent to memset (&foo, NULL, sizeof foo);
. Now with C++11, this has started yielding warnings:
foo.cpp:2:19: warning: missing field 'st_mode' initializer [-Wmissing-field-initializers]
struct stat s = {0};
^
This is because of the new initializer syntax of C++11, and the warning implies I am not initializing all members. What is the preferred way to instantiate and initialize a struct stat
in C++11?