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

Username
  

Password
  





  5.5 and groups of preprocessing
Posted by: lovewar - 03-11-2015, 06:44 AM - Forum: 8.5 Identifers - Replies (1)

such as

Code:
#ifndef NO_TAG
static void log (const char *format, ...)
{
}
#else
#if defined(__STDC_VERSION__)
#define log(...) do { } while (0)    // here
#endif
#endif
and, the identifier(log) exists after preprocssing has been performed:
Code:
static void log (const char *format, ...)   // does it apply to #define log ?
{
}
I have a question regarding rule 5.5: does the function(log) apply to #define log ?

Print this item

  Rule 2.4 and tag used in typedef
Posted by: lovewar - 30-10-2015, 09:05 AM - Forum: 8.2 Unused code - Replies (2)

Would the following examples be compliant with rule #2.4?

Code:
typedef struct cood cood_t;
struct cood {                    // here,  is the tag "cood" compliant?
    uint8_t  id;
};

Print this item

  10.5 Iterating over an enum
Posted by: dermiem - 29-10-2015, 04:32 PM - Forum: 8.10 The essential type model - Replies (3)

I usually define a enum in a project specific H file, to represent a set of signals:
typedef enum {
ADC_VBAT
ADC_FEEDBACK,
ADC_VOLTAGE,

ADC_NUM_SIGNALS
} adc_t ;

And then in the reusable C file, iterate over the configured set of signals. For example, to set the initial value of the averaged signal:

uint8_t i ;

for (i=0U; i < (uint8_t) ADC_NUM_SIGNALS; i++)
{
AdcClearAverage((adc_t) i) ;
}

where AdcClearAverage takes a parameter of type adc_t.

But this now generates warning 10.5 as an unsigned type is being cast to an enum.
What is the correct way to iterate over an enumeration?

Print this item

  Rule 19.1 and assignment of one element of array
Posted by: lovewar - 29-10-2015, 05:41 AM - Forum: 8.19 Overlapping storage - Replies (1)

Would the following examples be compliant with rule #19.1?

Code:
int16_t a[20];
void g(void)
{
    int16_t *p = &a[0];
    int16_t *q = &a[0];
    *p = *q;              /* Compliant - exception 1 */
}
void f(void)
{
    int16_t *p = &a[0];
    int16_t *q = &a[1];
    *p = *q;                     // here, is it Compliant ?
}

Print this item

  Rule 10.3 Does exception 1 apply to case labels?
Posted by: grunwald - 15-10-2015, 12:30 PM - Forum: 8.10 The essential type model - Replies (2)

Rule 10.3 covers assignment (as defined in the glossary) and the conversion of the constant expression in case labels.

Exception 1 says "A non-negative integer constant expression of essentially signed type may be assigned to an object of essentially unsigned type if its value can be represented in that type."

Is this exception intended to be restricted to assignment; or does it also apply to case labels?

Code:
switch (u8a) // controlling expression is essentially unsigned
{
    case 1: break; // '1' is essentially signed; 10.3 violation?
    case 2: break;
    default: break;
}

Print this item

  10.3 and essential type of & expression
Posted by: lovewar - 15-10-2015, 05:54 AM - Forum: 8.10 The essential type model - Replies (1)

Would the following examples be compliant with rule #10.3?

Code:
void foo(void) {
  uint8_t u8a = getCode();
  
  sint32_t s32a = u8a & 0xFF;    // here
}

Would the following examples be non-compliant with rule #10.3?
Code:
void foo(void) {
  uint8_t u8a = getCode();
  
  uint8_t u8b = u8a & 0xFF;    // here
}

Print this item

  Rule 18.4, 10.1, and the "type" of pointer to object
Posted by: michael.metivier - 01-10-2015, 06:48 PM - Forum: 8.18 Pointers and arrays - Replies (1)

Within our development group, there has been some discussion as to whether or not the construction

Code:
void test(uint8_t * up)
{
    bool invalid = !up;
    ...
}
is valid with regard to the usage of '!' against a pointer. According to the 18.X rules, '!' is not disallowed for use on pointers, but the explanation of Rule 10.1 with regards to the appropriate essential type for use with '!' would indicate that, as a non-Boolean, its use on pointers should be disallowed.

Do pointers have an "essential type" under the essential type model and what is the correct interpretation in this case?

Print this item

  Rule 5.9 - Scope of uniqueness
Posted by: jade - 11-09-2015, 04:49 PM - Forum: 8.5 Identifers - Replies (2)

In Rule 5.9, the amplification says that the identifier name should be unique across all name spaces and translation units. This is an expansion of what's in the rule header, but is consistent with the purpose of the "Amplification" sections. However, the examples imply that identifiers can be unique if there is no linkage. Isn't this a contradiction?

Print this item

  ISR function prototype generates error message in QAC
Posted by: vignesh081191 - 10-09-2015, 01:25 PM - Forum: General Questions - No Replies

In our project, we are using atmel microcontroller attiny24A. We are doing static analysis for our single file source code using QAC version 8.0.

The interrupt header file is include in the source file for interrupt usage and we dont get any issue in that
#include

But
We are getting the following error in the declaration of ISR function prototype.
ISR(TIM0_COMPA_vect);
^
Err(9:0926) [S] Expected: ) ,.

Functionality wise the code is working fine. So we have no idea what the QAC is expecting whether it misunderstands the ISR or not?

help me out guys...

Print this item

  5.8 and external identifiers in different header file
Posted by: lovewar - 25-08-2015, 01:39 AM - Forum: 8.5 Identifers - Replies (1)

Would the following examples be non-compliant with rule #5.8?

Code:
/* file 1. h */
extern int32_t count;    
extern void foo(void);

/* file 2.h */
extern int32_t count;   // here
extern void zoo(void);

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,309
» Latest member: 1fuhd
» Forum threads: 1,066
» Forum posts: 2,933

Full Statistics

Online Users
There are currently 115 online users.
» 0 Member(s) | 111 Guest(s)
Bing, DuckDuckGo, Google, UptimeRobot

Latest Threads
13.2 Was TC2 correctly ap...
Forum: 8.13 Side effects
Last Post: misra-c
08-10-2026, 12:47 PM
» Replies: 1
» Views: 625
20.12 Does the stringific...
Forum: 8.20 Preprocessing directives
Last Post: misra-c
08-10-2026, 12:40 PM
» Replies: 1
» Views: 554
13.3 Should side effects ...
Forum: 8.13 Side effects
Last Post: misra-c
08-10-2026, 12:37 PM
» Replies: 1
» Views: 428
11.6 pointer to pointer t...
Forum: 8.11 Pointer type conversions
Last Post: misra-c
08-10-2026, 12:21 PM
» Replies: 2
» Views: 1,032
What is the UTLR of -1?
Forum: 8.10 The essential type model
Last Post: misra-c
08-10-2026, 12:15 PM
» Replies: 1
» Views: 598
10.3 Clarify if narrower ...
Forum: 8.10 The essential type model
Last Post: misra-c
08-10-2026, 11:57 AM
» Replies: 1
» Views: 508
It 8.12 intended to be so...
Forum: 8.8 Declarations and defnitions
Last Post: misra-c
08-10-2026, 11:50 AM
» Replies: 1
» Views: 455
Rule 0.1.1 Example f4
Forum: 4.0 Language independent issues
Last Post: cgpzs
07-10-2026, 11:07 AM
» Replies: 3
» Views: 727
Rule 6-2-2 Usage of std::...
Forum: 6.6 Statements (C++)
Last Post: misra cpp
25-09-2026, 05:43 PM
» Replies: 1
» Views: 437
M5-0-4 switch over unscop...
Forum: 6.5 Expressions (C++)
Last Post: misra cpp
25-09-2026, 01:00 PM
» Replies: 3
» Views: 539