Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Underlying type of character constants and \"plain char
#5
While C considers plain char, signed char and unsigned char to be integral types, MISRA-C considers plain char to be a distinct underlying type which is used only for \"character\" data.

From your examples,

Code:
unsigned int c = 'x';  /* Not a \"conversion from signed to unsigned\" violation? */

This breaks rule 6.2.

Code:
void foo(int x) {
  unsigned int c = x;  /* Violation: conversion from signed to unsigned. */
}


This breaks 10.1.
Posted by and on behalf of the MISRA C Working Group


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)