Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As Bart van Ingen Schenau also stated I think that the standardization committee wanted to put as few restrictions on the representation of pointers as possible. From a compiler point of view it would be useful to have a distinct representation for <code>int *</code> and <code>int const *</code>, because constants could be placed in a bigger or smaller memory and consequently smaller pointers could be used to point into the smaller memories. This would however have meant that the <code>%s</code> format specifier of <code>printf</code> should come in two versions, one for a constant string and one for a non-constant string. This would break a lot of legacy code and my guess is that the standardization committee lacked the courage to enforce that onto the community. And probably rightfully so. As there are no compelling reasons to enforce the same representation for <code>int **</code> and <code>int const **</code>, they left it that way. Using a different representation for these pointer is however hardly ever useful, except maybe for some corner case applications.</p> <p>They might also have decided that <em>only</em> <code>char *</code> and <code>char const *</code> should have the same representation, just to save <code>%s</code>, but maybe there are some other interfaces that require equality for pointers to other primitive types as well.</p> <p>Similarly it would on some systems be desirable to have a different pointer representation for something in global memory, something on the stack and something in the heap. It is however possible in C to use a pointer in such a way that it may contain either such pointer (again you could think of varargs) and it is thus required to at least have a pointer representation that can represent all of them.</p> <p>In the Embedded-C extension on C memory space have been introduced to explicitly allow the programmer to get data from different data-buses without the need for a pointer type that can represent them all. Such memory spaces could also be used to specify dedicated memories for constants, heap etc. Thus allowing more efficient pointer representations.</p> <p>A colleague of mine also mentioned that K&amp;R prototypes, or better the absence thereof, are still allowed. In such cases the compiler can not detect the difference in representation between a parameter declaration and use. This would undoubtedly lead to many undetected problems in legacy software. These issues could have been resolved by requiring the use of a common representation on parameter passing (including varargs) as for example is done for <code>float</code> to <code>double</code> in varags, but that would also compromise the intended efficiency of a different representation.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload