Skip to content

Latest commit

 

History

History
46 lines (39 loc) · 1.07 KB

compiler-warning-level-3-c4197.md

File metadata and controls

46 lines (39 loc) · 1.07 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Warning (level 3) C4197
Compiler Warning (level 3) C4197
11/04/2016
C4197
C4197
f766feef-82b0-4d81-8a65-33628c7db196

Compiler Warning (level 3) C4197

'type' : top-level volatile in cast is ignored

The compiler detected a cast to an r-value type which is qualified with volatile, or a cast of an r-value type to some type that is qualified with volatile. According to the C standard (6.5.3), properties associated with qualified types are meaningful only for l-value expressions.

The following sample generates C4197:

// C4197.cpp
// compile with: /W3
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>

void sigproc(int);
struct S
{
   int i;
} s;

int main()
{
   signal(SIGINT, sigproc);
   s.i = 1;
   S *pS = &s;
   for ( ; (volatile int)pS->i ; )   // C4197
      break;
   // for ( ; *(volatile int *)&pS->i ; )   // OK
   //    break;
}

void sigproc(int) // ctrl-C
{
   signal(SIGINT, sigproc);
   s.i = 0;
}