C++ coding and analysis example

来源:公众号“汽车安全前瞻研究”
2020-05-12
1669

[0] for-coding

intmain()

{

usingnamespace std;

int n_int=INT_MAX;

inti; //create a counter

}

cout<< ''C++ knows loops. n'''

cout<< ''C++ knows when to stop. n'';

return0;

 

[1] for-coding location

[2-0] Program flow without interrupts

[2-1] Program flow with interrupts

[3] Data flow

[4-1] control flow without interruption

[4-2] control flow with interruption

Above things had been comeing from the usual methodology, and we can derive out some more detail from ISO 26262-2018, chapter 6 for the unit design and coding methodology:


Here in C++, the 1a~1i can be used as guidance, following is some illlustration:

①enforcement of low complexity, applied in ASIL A~ ASIL D, describing more in the coding complexity, like no bigg function designs, complex coding structures;

② use of language subsets, shall be clear defined, lesson learned the good practise, and run-time error or real time errors shall be avoided;

③ strong typing not in specialty in C++, but for all of the languages, C language has  this kinds of problems, and C++ will be better, as well in C++ library, but we have to as well discuss more about this topic.


Thank you for the reading, and any comments we can discuss further.



收藏
点赞
2000