MISRA Discussion Forums
Definition of "object" - 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:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21)
+---- Forum: 8.8 Declarations and defnitions (https://forum.misra.org.uk/forumdisplay.php?fid=163)
+---- Thread: Definition of "object" (/showthread.php?tid=1486)



Definition of "object" - mz99 - 17-04-2019

The word "object" is used in some rules of MISRA-C:2012. (e.g. Rule-8.9)
What is the definition of "object" in MISRA-C:2012?
Which of the following are considered as "object" in MISRA-C:2012?
  • Variable
  • Const-qualified variable
  • Function
  • Object-like macro
  • Function-like macro



Re: Definition of "object" - dg1980 - 17-04-2019

First sentence here: https://en.wikipedia.org/wiki/Object_(computer_science)
Anything else would really surprise me:) - but let's wait for an official reply.


Re: Definition of "object" - twakita - 23-04-2019

(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


Re: Definition of "object" - mz99 - 26-04-2019

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.


Re: Definition of "object" - mz99 - 26-04-2019

.


Re: Definition of "object" - mz99 - 26-04-2019

.


Re: Definition of "object" - misra-c - 02-05-2019

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