dimanche 29 mars 2015

Good C-coding style for multiple lines if conditions

I am proramming on a project and I got the problem, that i´ve got a lot of if conditions and it might get really hard for other people to read. Here is the C - Code.


I couldn´t find a similiar question on the internet yet. Do you have an idea or example how to make it more readable?



if( ((g_cycle_cnt == uartTxSecondaryMsg[3][msgPos[3]].sliceNo) || //correct slicenumber...
(uartTxSecondaryMsg[3][msgPos[3]].sliceNo == -1) || // or as fast as possible...

( (uartTxSecondaryMsg[3][msgPos[3]].sliceNo == -2) &&
((uartTxSecondaryMsg[3][msgPos[3]].timeFrameBegin>=g_uptime_cnt) &&
(uartTxSecondaryMsg[3][msgPos[3]].timeFrameEnd<=g_uptime_cnt)))) &&

((dataProcessingFlag & SECONDARY_MSG_ANNOUNCED_CH4) == SECONDARY_MSG_ANNOUNCED_CH4) )

Aucun commentaire:

Enregistrer un commentaire