0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

R7 misra c 2012 example suite

0
Last updated at Posted at 2025-07-16
ms3_support.c
#include "mc3_types.h"
#include "mc3_header.h"

/* ダミー実装群 */
void use_uint16(uint16_t val) {(void)val;}
void use_int32(int val) {(void)val;}
void use_int64(int64_t val) {(void)val;}
void use_uint32(uint32_t val) {(void)val;}
void use_uint64(uint64_t val) {(void)val;}
void use_int128(int128_t val) {(void)val;}
void use_uint128(uint128_t val) {(void)val;}
void use_float128(float128_t val) {(void)val;}
void use_const_char_ptr(const char *p) {(void)p;}
void use_const_volatile_char_ptr(const volatile char *p) {(void)p;}

/* f1, f2 は以下のように簡単に定義すればOK */
void f1(char *s1) {(void)s1;}
void f2(const char *s2) {(void)s2;}
r7.sh
gcc R_07_01.c  R_07_02.c  R_07_03.c R_07_04.c R_07_support.c  R_07_system.c ms3_support.c -o r7.exe
bash
$ ./r7.exe
Segmentation fault (core dumped)
ms3_support.c
inst19@teachB:~/misra2/Example-Suite$ vi ms3_support.c
inst19@teachB:~/misra2/Example-Suite$ cat ms3_support.c
#include "mc3_types.h"
#include "mc3_header.h"

/* ダミー実装群 */
void use_uint16(uint16_t val) {
//      (void)val;
}
void use_int32(int val) {
//      (void)val;
}
void use_int64(int64_t val) {
//      (void)val;
}
void use_uint32(uint32_t val) {
//      (void)val;
}

void use_uint64(uint64_t val) {
//      (void)val;
}
void use_int128(int128_t val) {
//      (void)val;
}
void use_uint128(uint128_t val) {
//      (void)val;
}
void use_float128(float128_t val) {
//      (void)val;
}
void use_const_char_ptr(const char *p) {
//      (void)p;
}
void use_const_volatile_char_ptr(const volatile char *p) {
//      (void)p;
}

/* f1, f2 は以下のように簡単に定義すればOK */
void f1(char *s1) {
//      (void)s1;
}
void f2(const char *s2) {
//      (void)s2;
}
bash
$ ./r7.sh
R_07_04.c: In function ‘R_7_4’:
R_07_04.c:46:4: warning: assignment of read-only location ‘"0123456789"[0]’
   46 |    "0123456789"[0] = '*';             /* Non-compliant */
      |    ^~~~~~~~~~~~
inst19@teachB:~/misra2/Example-Suite$ ./r7.exe
Segmentation fault (core dumped)

$ ./r7.sh
In file included from R_07_04.h:14,
                 from R_07_04.c:20:
mc3_types.h:23:1: error: expected ‘,’ or ‘;’ before ‘typedef’
   23 | typedef _Bool bool_t;
      | ^~~~~~~
R_07_04.c: In function ‘R_7_4’:
R_07_04.c:48:4: warning: assignment of read-only location ‘"0123456789"[0]’
   48 |    "0123456789"[0] = '*';             /* Non-compliant */
      |    ^~~~~~~~~~~~
$ grep  bool *.h
e$ grep  bool *.h
D_04_01.h:extern bool msg_header_valid ( const char * c );
R_13_05.h:typedef bool_t ( *fnptr ) ( uint16_t y );
R_13_05.h:extern bool_t persist ( uint16_t y );
R_15_04.h:extern bool ExitNow ( uint32_t e );
R_15_04.h:extern bool BreakNow ( uint32_t b );
R_15_04.h:extern bool GotoNow ( uint32_t g );
R_15_06.h:extern bool_t fn ( void );
R_15_06.h:extern bool_t process_data ( void );
mc3_header.h:extern bool get_bool ( void );
mc3_header.h:extern bool *get_bool_ptr ( void );
mc3_header.h:extern void use_bool ( bool use_bool_param );
mc3_header.h:extern void use_bool_ptr ( bool *use_bool_ptr_param );
mc3_types.h:#include <stdbool.h>
mc3_types.h:typedef _Bool bool_t;
mc3_types.h:typedef          int            bool_t;
mc3_types.h:typedef          int            bool;
misra2012.h:#include <stdbool.h> /* define true */
misra2012.h:typedef bool bool_t;
misra2012.h:typedef _bool bool_t;
misra2012c.h:#include <stdbool.h> /* define true */
misra2012c.h:typedef bool bool_t;
misra2012c.h:typedef _bool bool_t;
misrac2012.h:#include <stdbool.h> /* define true */
misrac2012.h:typedef bool bool_t;
misrac2012.h:typedef _bool bool_t;
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?