C++11 on exotic hardware

后端 未结 4 1314
醉话见心
醉话见心 2020-12-07 01:30

There was a question like this before, in 2011: Exotic architectures the standards committees care about

Now, I\'d like to ask a very similar question, but this time

4条回答
  •  长情又很酷
    2020-12-07 02:12

    When people say that something is implementation defined, this doesn't apply only to memory model, basic variable sizes etc. (i.e. hardware implementation), but rather the fact it may depend on a particular compiler implementation (different compilers may handle some things differently and they often do) and/or operating system the program is compiled for. So even though the overwhelming majority of hardware may be non-exotic according to your definition, still "you cannot depend on that, it is implementation defined" ;)

    Example: C++ standard states that the long double type has to be at least as large as regular double (i.e. 8 bytes), but it's implementation defined, and, in fact, whereas g++ implements long double as 16 byte long for x64 platform, latest VC++ compiler sticks to the minimum and as for now long double is only 8 byte long just like double, but this may change in the future - you never know as it's implementation defined and Microsoft is free to change it anytime they want and the standard will still be adhered to.

    It's not the exact answer to the question you have asked, but answers the last paragraphs of your question ("how much can I depend on the standard?") and clearly this may make you review the way you think of this problem. Also it's a bit long to be a comment and would be less readable, so I'll just leave it here.

提交回复
热议问题