Page 146 - C-Language
P. 146

retrieve it (you can see more about this problem here). We've done all of this in the above
        examples.


         int a3(); /* you should be able to call a3 */


        This one tells the compiler that you'll attempt to call a3. In this case a3 refers to function instead of
        an object. One difference between object and function is that functions will always have some sort
        of linkage. Examples:


         void f1()
         {
             {
                 int f2(); /* 1 refers to some function f2 */
             }

             {
                 int f2(); /* refers to the exact same function f2 as (1) */
             }
         }


        In the above example, the 2 declarations refer to the same function f2, whilst if they were
        declaring objects then in this context (having 2 different block scopes), they would have be 2
        different distinct objects.


         int (*a3)(); /* you should be able to apply indirection to `a3` and then call it */


        Now it may seems to be getting complicated, but if you know operators precedence you'll have 0
        problems reading the above declaration. The parentheses are needed because the * operator has
        less precedence then the ( ) one.

        In the case of using the subscript operator, the resulting expression wouldn't be actually valid after
        the declaration because the index used in it (the value inside [ and ]) will always be 1 above the
        maximum allowed value for this object/function.


         int a4[5]; /* here a4 shouldn't be accessed using the index 5 later on */


        But it should be accessible by all other indexes lower then 5. Examples:


         a4[0], a4[1]; a4[4];


        a4[5] will result into UB. More information about arrays can be found here.


         int (*a5)[5](); /* here a4 could be applied indirection
                         indexed up to (but not including) 5
                         and called */


        Unfortunately for us, although syntactically possible, the declaration of a5 is forbidden by the
        current standard.






        https://riptutorial.com/                                                                             122
   141   142   143   144   145   146   147   148   149   150   151