Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC2012-Rule-1.5_f

In this section:
Synopsis

(Required) Obsolescent language features shall not be used.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

The use of ungetc on a binary stream where the file position indicator is zero prior to the call is an obsolescent feature.

Coding standards
MISRA C:2012 Rule-1.5

(Required) Obsolescent language features shall not be used.

Code examples

The following code example fails the check and will give a warning:

#include <stdio.h>

void fail(void) 
{
   FILE *fp;
   ungetc ('+', fp);
}

The following code example passes the check and will not give a warning about this issue:

#include <stdio.h>

void pass(void) 
{
   FILE *fp;
   fp = fopen("file.txt", "r");
   getc(fp);
   ungetc ('+', fp);
}