vendredi 6 mars 2020

So how to fix warnings on this simple RAII close caller?

So I get this warning for the line:

warning: ignoring attributes on template argument ‘int (*)(DIR*) {aka int (*)(__dirstream*)}’ [-Wignored-attributes]
     std::unique_ptr<DIR, decltype(closedir)*> cd(od, closedir);

So I can see the compiler hint attribute __nonnull in the spec:

/* Close the directory stream DIRP.
   Return 0 if successful, -1 if not.

   This function is a possible cancellation point and therefore not
   marked with __THROW.  */
extern int closedir (DIR *__dirp) __nonnull ((1));

So why doesn't declspec copy that attribute across, and how do I make it shut up, without writing something ugly?

Posted for c++11, but I would be happy to hear "they fixed it later"

Aucun commentaire:

Enregistrer un commentaire