Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





  19.7 no function-like macros
Posted by: Manni - 25-04-2006, 08:58 AM - Forum: 6.19 Preprocessing Directives - Replies (1)

Hi

Two questions about this rule:

1. Have somebody examples short for function-like macros?
2. When is a macro funktion-like?

best regards,
Manni

Print this item

  Examples for 12.9 - unary minus operator
Posted by: Manni - 24-04-2006, 12:00 PM - Forum: 6.12 Expressions - Replies (1)

Hi

Question about Rule 12.9: The unary minus operator shall not be applied to an expression whose underlying type is unsigned.

Code:
uint32_t u_int_a;
uint32_t u_int_b;

u_int_a = -u_int_b;
1. Is this incorrect?
2. Shows this example, what the rule 12.9 mean?



4. Is this correct? (a = int)
Code:
uint32_t int_a;
uint32_t u_int_b;

u_int_a = -(int32_t)u_int_b;


5. Is this correct, too? (a = uint)
Code:
uint32_t u_int_a;
uint32_t u_int_b;

u_int_a = -(int32_t)u_int_b;
6. I think it it is correct to rule 12.9, but breach 10.1. Right?


7. Have somebody good examples for rule breaks? And how to solve it?

best regards,
Manni

Print this item

  writing a MISRA-C:2004 tutorial
Posted by: Manni - 19-04-2006, 01:09 PM - Forum: General Questions - Replies (9)

Hi

I want to start writing a helping document and tutorial about MISRA-C:2004 rules. The document should contain the following points.

1. Reasons for specific MISRA-C rules. (Why is it important to observe the rule)
2. Howto handle specific rules
3. Howto conceive specific rules
4. Exampels for breaches of the specific rules, and how to solve it. (with example, too)

Are there any good sources and publications, which helping to write such a tutorial?

best regards,
Manni

EDIT:
I know that there are explanations like this in miscra-c rules included. But I mean more comprehensive explanation.

Print this item

  Welcome
Posted by: david ward - 07-04-2006, 10:34 AM - Forum: MISRA SRfP Discussions - Replies (1)

This new forum has been set up for asking questions about and discussing MISRA's \"Software Readiness for Production\" guidelines.

Print this item

  The Meaning of Rule 12.6?
Posted by: Hammer - 06-04-2006, 07:30 AM - Forum: 6.12 Expressions - Replies (1)

I am trying to understand this rule and need someone to clarify its exact meaning.

which of the following are violations of Rule 12.6?

Code:
if((x==y)|(y==a))/*Violation?, could || have been meant?*/
   {    

   }
This is a violation of the old equivalent rule 36 but is it still a violation now?

Code:
a=a+y+x+(x||y);
/*Violation, effectively boolean expression used with + operator*/

Code:
int32_t x=5;
int32_t y=11;

if(x||y) /*Could this be a violation??? because x and y are not effectively boolean*/
   {
      
   }


Thanks for you help!

Print this item

  Rule 5.1
Posted by: quangp - 05-04-2006, 10:37 PM - Forum: 6.5 Identifiers - Replies (1)

Need clarification on rule 5.1 (equivalenet to rule 11 in MISRA C1):

Does this rule disallow to use identifier that has more than 31 characters? Even though the first 31 characters are guaranteed to be distinct.

Thanks,

quangp

Print this item

  implicitly cast
Posted by: warawut - 05-04-2006, 03:57 AM - Forum: General Questions - Replies (3)

According to source code below, please kindly help me to clear understanding whether where are the implicitly cast and they will cast to what type?

Warning: Unsuffixed integral literal implicitly cast to another type.


Source code
struct {
unsigned char multiple: 1;
unsigned char event: 1;
unsigned char checksum: 1;
unsigned char conditional: 1;
} flag;
...

void transmit(void)
{
…
if (flag.conditional == 1) { [color=red][b]

Print this item

  Rule 19.4
Posted by: aravind - 31-03-2006, 07:20 PM - Forum: 6.19 Preprocessing Directives - Replies (1)

Is the usage of ternary operator (? :) inside a C macro violation of rule 19.4. For e.g. the following function-like macro

#define abs(x) (((x) >= 0) ? (x) : -(x))

According to Rule 19.4 - C macros shall only expand to a braced initialiser, a constant, a parenthesized expression, a type qualifier, a storage class specifier or a do-while construct.

Does the above function-like macro conform to rule 19.4?

Print this item

  Integral promotion.
Posted by: warawut - 01-03-2006, 04:08 AM - Forum: General Questions - Replies (2)

I have some doubt about the integral promotion whether how integral promotion's rule perform with the unsuffixed constant (hexadecimal).
Example:

16bit ECU
0xffff -----> Will it promote to \"int\" or \"unsigned int\"?
0xffffffff -----> Will it promote to \"int\" or \"unsigned int\"?

32bit ECU
0xffff -----> Will it promote to \"int\" or \"unsigned int\"?
0xffffffff -----> Will it promote to \"int\" or \"unsigned int\"?

Who know how does it perform with hexadecimal.
Please kindly give me the answer.

Thanks in advance,
Warawut.

Print this item

  Rule 1.1 and Number of characters for Header File name
Posted by: lv - 21-02-2006, 05:12 PM - Forum: 6.1 Environment - Replies (1)

The rule 1.1 deals with limits defined in chapter 5.2.4 of ISO-9899:1990 norm.

But for the #include preprocessing directive, the 9899:1999 (and so, I suspect that the C90 is more restrictive) specify in chapter 6.10.2 some restriction (limits) about the sequence placed between the \" \" or < > delimiters:

The implementation shall provide unique mappings for sequences consisting of:
- one or more digits (no case sensitive)
- followed by a period
- followed by a single letter.
- The mapping is restricting to eight significant characters before the period.


So if the sequence between \" and < > delimiters is specified, then the header file names are impacted.

I would like to know if it is MISRA compliant to have a header file name with more than 8 characters before the period ?
(Example: FooComponent_Api.h)


Thanks in advance for your answer.

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,121
» Latest member: Alain.Djempe
» Forum threads: 968
» Forum posts: 2,657

Full Statistics

Online Users
There are currently 173 online users.
» 0 Member(s) | 171 Guest(s)
Bing, Google

Latest Threads
A13-5-4 opposite operator...
Forum: AUTOSAR C++:2014 rules
Last Post: aromauld
26-04-2024, 03:34 PM
» Replies: 0
» Views: 65
C++17 [[fallthrough]]; at...
Forum: 6.6 Statements (C++)
Last Post: mshawa
22-04-2024, 06:29 PM
» Replies: 0
» Views: 72
cvalue and constant integ...
Forum: AUTOSAR C++:2014 rules
Last Post: misra cpp
19-04-2024, 04:53 PM
» Replies: 1
» Views: 230
Rule 6-2-3 and C++17 [[fa...
Forum: 6.6 Statements (C++)
Last Post: misra cpp
19-04-2024, 04:48 PM
» Replies: 1
» Views: 203
10.2.3 Amplification
Forum: 4.10 Declarations
Last Post: misra cpp
12-04-2024, 02:20 PM
» Replies: 1
» Views: 238
Rule 7.0.5 Example potent...
Forum: 4.7 Standard conversions
Last Post: misra cpp
12-04-2024, 01:54 PM
» Replies: 1
» Views: 183
Rule 0.2.4 non-compliant ...
Forum: 4.0 Language independent issues
Last Post: misra cpp
12-04-2024, 01:51 PM
» Replies: 1
» Views: 216
Further guidance on MISRA...
Forum: 8.10 The essential type model
Last Post: mshawa
09-04-2024, 02:29 PM
» Replies: 0
» Views: 133
MISRA AC SLSF:2023 AMD1
Forum: MISRA AC resources
Last Post: david ward
05-04-2024, 01:56 PM
» Replies: 0
» Views: 153
MISRA AC GMG:2023 release...
Forum: MISRA AC GMG discussions
Last Post: misra-ac
25-03-2024, 06:01 PM
» Replies: 2
» Views: 532