Posts: 1
Threads: 0
Joined: Aug 2016
Reputation:
0
(This is not offical reply from MISRA)
"object" is defined in ISO-C. (MISRA C is a subset of ISO-C.)
object (ISO/IEC 9899 section 3.14):
region of data storage in the execution environment,
the contents of which can represent values (1)(2)
Mostlikely, "object" meanings RAM area which is assigned for a variable.
-- refs --
(1) ISO/IEC 9899: 1990,Programming languages ― C, ISO, 1990
(2) ISO/IEC 9899: 1990,Programming languages ― C, ISO, 1999
<t></t>
Posts: 5
Threads: 2
Joined: Feb 2019
Reputation:
0
I accidentally posted the same replies...
Thank you for the comments.
So, according to the definition of "object", would they be regarded as an "object", or NOT an "object"?
Variable -> "object", because it's stored in RAM.
Const-qualified variable -> ?, depends on whether it's stored in ROM or RAM.
Function -> not "object", because it can't represent values.
Object-like macro -> not "object", because it's not stored in RAM.
Function-like macro -> not "object", because it's not stored in RAM.
<t></t>
Posts: 632
Threads: 18
Joined: Jan 2006
Reputation:
1
The MISRA C:2012 guidelines uses the definition as the C99 standard. ( see section 3.14 and 6.2.1 ). Regarding your specific examples:
Code:
* Variable // object
* Const-qualified variable // object
* Function // not an object
* Object-like macro // not an object, but may expand to an object
* Function-like macro // not an object, but may expand to an object
Most of the MISRA C:2012 guidelines, including rule 8.9 apply after macro expansion.
For example:
Code:
int x; // object
int fn(int y); // function
#define MYMAC(Z) Z
int MYMAC(r) = 3; // expands to int r = 3; which is an object definition
MYMAC(fn)(x); // expands to fn(x); which is a function call
Posted by and on behalf of the MISRA C Working Group