Constant array types in C, flaw in standard?

前端 未结 3 1878
迷失自我
迷失自我 2021-01-04 02:21

Paragraph 6.7.3.8 of the C99 spec states

If the specification of an array type includes any type qualifiers, the element type is so-qualified, not the array ty
3条回答
  •  Happy的楠姐
    2021-01-04 03:07

    The situation is awkward with pointers (ie, arrays), but here's my recollection of the details:

    const double *ap is a pointer to a constant double;

    double *const ap is a constant pointer to a double;

    const double *const ap is a constant pointer to a constant double;

    So I believe it is possible to do what you're asking, although I've not tried this in years -- the gcc option you're using wasn't available the last time I did this!

    EDIT: This answer is not correct for the question - I'm leaving it to preserve the comments below, which clarify the problem for mere mortals (or rusty C developers...)

提交回复
热议问题