A question for Amplification of Rule 3.2.

Moderators: misra-c, david ward

Post Reply
KumikoItoh
Posts: 6
Joined: Thu Feb 20, 2014 6:48 am
Company: HitachiAutomotiveSystems

A question for Amplification of Rule 3.2.

Post by KumikoItoh » Mon Jun 09, 2014 7:35 am

I have a question for Amplification of Rule 3.2.

Your guideline has the following description in item "Amplification" of Rule 3.2.

"If the source file contains multibyte characters, they are converted to the source character set before any splicing occurs."

However, I did not understand the aim of this description well. Will you explain the details?

Especially, I do not understand why "multibyte characters" are related to "splicing".

Do you intend to explain the supporting case ,"multibyte characters including "\" character"?

I suppose it as follows.

"\" character included in "multibyte characters" is different from "line-splicing \",so there are not mixed.

For example,
uint16_t x=0; // 表
if( b)
{
x++;
}

Even If this character"表" incudes "\" character,
this "\" is not a meaning of "line-splicing".


Is this correct?

Please teach me.

Best Regards,
Kumiko Itoh

misra-c
Posts: 555
Joined: Thu Jan 05, 2006 1:11 pm

Re: A question for Amplification of Rule 3.2.

Post by misra-c » Wed Jun 25, 2014 6:09 pm

The line in the amplification is present to remind readers that the interpretation of bytes in the physical source file occurs in translation phase 1 and the line splicing in translation phase 2.

For example, in UTF16 the 表 "han honour" multi-byte character corresponds to the bytes 0x5C0A.

If the physical source file was interpreted as an ASCII file, the bytes sequence 0x5COA would be interpreted as backslash (0x5C) and new line (0x0A);

This rule applies to characters rather than byte sequences. There will be no violation of this rule, providing the analyser has done a correct translation according to translation phase 1 in the standard as implemented by the compiler.
---
Posted by and on behalf of
the MISRA C Working Group

mukundi
Posts: 1
Joined: Tue Sep 18, 2018 7:39 am
Company: KPIT Technologies Limited

Re: A question for Amplification of Rule 3.2.

Post by mukundi » Wed Sep 19, 2018 10:19 am

Hi,

I had a simple doubt regarding the code snippet provided here. Does usage of '//' for commenting violate any rule because '//' was initially introduced in C++ and I wonder if it can be used with a C compiler? [Note: I am really new to this forum and I am studying the various MISRA C Guidelines.]

Please enlighten me in this topic.

Regards,
Mukund Iyer

misra-c
Posts: 555
Joined: Thu Jan 05, 2006 1:11 pm

Re: A question for Amplification of Rule 3.2.

Post by misra-c » Thu Oct 04, 2018 10:54 am

The // comment was introduced in C99 and is permitted by the MISRA guidelines if the project is using C99. If the project is using C90 the use of // will violate rule 1.2 "Language extensions should not be used".
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “8.3 Comments”