MISRA C:2004 rule 19.4 / extension - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4) +--- Forum: MISRA-C: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17) +---- Forum: 6.19 Preprocessing Directives (https://forum.misra.org.uk/forumdisplay.php?fid=43) +---- Thread: MISRA C:2004 rule 19.4 / extension (/showthread.php?tid=398) |
MISRA C:2004 rule 19.4 / extension - Laessle - 26-09-2007 In our code we want to use generic macros of kind #define macro(a) int array[2] = {a, a}; unfortunately a do-while-zero loop does not helps, cause defined objects are only known within the loop. So we would like to ask for a further exception of the described kind. In the attachment you will find an example to demostrate the intention of such macros. The program reads values of an Analog Digital Converter (via SPI) and writes modified values to a Pulswidth Generator (also via SPI). All transfers are coded in an array (Transfer_List). The contents of the array depends on the hardware (baudrate, data-format) and the tranfer-typ (read, write number of values). The C-file has no hardware dependant function. All hardware specific settings are encapsulated in the macro Create_Transfer_List. Modifying the hardware only needs to modify the macro. Further I/Os can be implemented very easily. We would appreciate your positve response. Mit freundlichen Grüßen/Best regards, Hans-Peter Lässle Control Systems ETC-D Continental Teves AG & Co. oHG Guerickestr. 7, D-60488 Frankfurt am Main P.O. Box 900120, D-60441 Frankfurt am Main Telefon/Phone: 0049 69 7603-5418 Telefax: 0049 69 7603-3990 E-Mail: [email protected] http://www.contautomotive.com _____________________________________________________ Continental Teves AG & Co. oHG, Guerickestr. 7, D-60488 Frankfurt am Main Sitz der Gesellschaft/Registered Office: Frankfurt am Main, Registergericht/Registered Court: Amtsgericht Frankfurt am Main HR A 27047, USt.-ID-Nr./VAT-ID-No. DE 112160365 Gesellschafter/Shareholders: Continental Aktiengesellschaft (geschäftsführend/managing) Vorsitzender des Aufsichtsrats/Chairman of the Supervisory Board: Dr. Hubertus von Grünberg Vorstand/Executive Board: Manfred Wennemer (Vorsitzender/Chairman), Dr. Alan Hippe, Gerhard Lerch, Dr. Karl-Thomas Neumann, Dr. Hans-Joachim Nikolin, Heinz-Gerhard Wente, William L. Kozyra (stv./Deputy) Sitz der Gesellschaft/Registered Office: Hannover, Registergericht/Registered Court: Amtsgericht Hannover HR B 3527 Continental Teves UK Ltd., Company Number 00700225, Ebbw Vale, Wales, Großbritannien/Great Britain _____________________________________________________ Proprietary and confidential. Distribution only by express authority of Continental AG or its subsidiaries. - misra-c - 11-12-2007 This use of macros requires a deviation to be raised. Where such use of macros creates clarity, its use is reasonable. Unconstrained use of macros can create complex code which may lead to unexpected behaviour. This rule attempts to constrain the use of macros to simple contructs. Well designed use of complex macros is possible, and can be justified using a deviation. Examination of the post-processed code is recommended. The use of macros will be reconsidered for MISRA-C3. |