gcc(gnu), clang(llvm)コンパイルエラー・警告比較(1) D_04_03.c, docker(155) error(51)
https://qiita.com/kaizen_nagoya/items/780be9109348340e20e0
MISRA C まとめ #include 、OSEK(99), coding(38)
https://qiita.com/kaizen_nagoya/items/f1a79a7cbd281607c7c9
inst19@teachB:/tmp/misra/Example-Suite$ gcc D_04_03.c clear_lib.c
D_04_03.c: In function ‘D_4_3_1’:
D_04_03.c:24:8: error: expected ‘(’ before ‘{’ token
24 | asm { "CLI" }; /* Non-compliant */
| ^
| (
D_04_03.c:24:15: error: expected ‘;’ before ‘}’ token
24 | asm { "CLI" }; /* Non-compliant */
| ^~
| ;
D_04_03.c:26:8: error: expected ‘(’ before ‘{’ token
26 | asm { "SEI" }; /* Non-compliant */
| ^
| (
D_04_03.c:26:15: error: expected ‘;’ before ‘}’ token
26 | asm { "SEI" }; /* Non-compliant */
| ^~
| ;
clear_lib.c:10:10: fatal error: misra_c.h: No such file or directory
10 | #include "misra_c.h"
| ^~~~~~~~~~~
compilation terminated.
inst19@teachB:/tmp/misra/Example-Suite$
gcc D_04_03.c
D_04_03.c:24: error: unterminated #else
24 | #ifdef DEBUG // O.K.
|
D_04_03.c
*
* Release: 2016-01-01
*
* Example from MISRA C:2012 ( THIS IS NOT A TEST SUITE )
*
* Copyright HORIBA MIRA Limited.
*
* See file READ_ME.txt for full copyright, license and release instructions.
*/
/*
* D.4.3
*
* Assembly language shall be encapsulated and isolated
*/
#include "mc3_types.h"
#include "mc3_header.h"
#include "D_04_03.h"
#define NOP asm(" NOP") /* Compliant, but breaks R.1.2 */
void main(void){
D_4_3(void);
}
static void D_4_3_1 ( void )
{
#ifdef DEBUG // O.K.
asm { "CLI" }; /* Non-compliant */
use_int16 ( 1 );
asm { "SEI" }; /* Non-compliant */
#elif MSC_VER
_asm { "CLI" }; /* Non-compliant */
use_int16 ( 1 );
_asm { "STI" }; /* Non-compliant */
#else // O.K.
asm ("CLI"); /* Non-compliant CLI:clear interrupt*/
use_int16 ( 1 );
asm ("STI"); /* Non-compliant STI:Set interrupt */
#endif
}
static void D_4_3_2 ( void )
{
NOP;
}
void D_4_3 ( void )
{
$ gcc D_04_03.c
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
/usr/bin/ld: /tmp/cc7c2DLv.o: in function `D_4_3_1':
D_04_03.c:(.text+0xf): undefined reference to `use_int16'
collect2: error: ld returned 1 exit status
$ gcc D_04_support.c
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
/usr/bin/ld: /tmp/ccMsKIUh.o: in function `D_4_main_support':
D_04_support.c:(.text+0x9): undefined reference to `D_4_1'
/usr/bin/ld: D_04_support.c:(.text+0xe): undefined reference to `D_4_3'
/usr/bin/ld: D_04_support.c:(.text+0x13): undefined reference to `D_4_4'
/usr/bin/ld: D_04_support.c:(.text+0x18): undefined reference to `D_4_5'
/usr/bin/ld: D_04_support.c:(.text+0x1d): undefined reference to `D_4_6'
/usr/bin/ld: D_04_support.c:(.text+0x22): undefined reference to `D_4_7'
/usr/bin/ld: D_04_support.c:(.text+0x27): undefined reference to `D_4_8'
/usr/bin/ld: D_04_support.c:(.text+0x2c): undefined reference to `D_4_9'
/usr/bin/ld: D_04_support.c:(.text+0x31): undefined reference to `D_4_10'
/usr/bin/ld: D_04_support.c:(.text+0x36): undefined reference to `D_4_11'
/usr/bin/ld: D_04_support.c:(.text+0x3b): undefined reference to `D_4_12'
/usr/bin/ld: D_04_support.c:(.text+0x40): undefined reference to `D_4_13'
/usr/bin/ld: D_04_support.c:(.text+0x45): undefined reference to `D_4_14'
collect2: error: ld returned 1 exit status