Condividi tramite


C6322

avviso C6322: blocco _except vuoto

Il messaggio indica che nel blocco _except non è presente codice, di conseguenza è possibile che le eccezioni non vengano gestite.

Esempio

Il codice seguente genera questo avviso:

#include <stdio.h>
#include <excpt.h>
#include <windows.h>

void fd(char *pch)
{
   __try
     {
       // exception rasied if pch is null
       *pch= 0 ;
     }
   __except(GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
     {
     }
}

Per risolvere il problema, utilizzare il codice seguente:

#include <stdio.h>
#include <excpt.h>
#include <windows.h>

void f(char *pch)
{
   __try
     {
       // exception rasied if pch is null
      *pch= 0 ;
     }
   __except(GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? 
               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
     {
       // code to handle exception
       puts("Exception Occurred");   
     }
}  

Vedere anche

Riferimenti

try-except Statement