Multiple local initialsaions in a single line

6.9 Initialisation

Moderators: misra-c, david ward

Post Reply
alon
Posts: 2
Joined: Thu Sep 15, 2011 9:17 am
Company: Elbt

Multiple local initialsaions in a single line

Post by alon » Tue Sep 20, 2011 7:10 am

Hello

dose a line of the form

Code: Select all

int i=0,j=0,k,l;
considered a misuse of the comma operator.
meaning, the line is considered as composed of multiple statements in a single line.
if so then what about, just plain

Code: Select all

int i,jk; 
Thanks

-Alon

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

Re: Multiple local initialsaions in a single line

Post by misra-c » Wed Sep 21, 2011 10:16 am

In an list of declarators, the comma is being used as a separator rather than an operator. There are no comma operators in the examples given and therefore no violation of Rule 12.10.
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “6.9 Initialisation”