Program portability

后端 未结 12 1271
栀梦
栀梦 2020-12-30 04:26

How to make sure that my program will be fully portable?

12条回答
  •  滥情空心
    2020-12-30 04:55

    Know the platforms that you intend to ship for. If some platform convention contradicts the standard, ignore the standard. I'm serious about that. For example, if you use the standard std::ifstream constructor, which takes a char* argument, you won't be able to open any files with Unicode filenames on Windows—you must use the nonstandard wchar_t* overload there. The functionality lost by not being able to open files that are allowed and legal on the platform severely outweighs the portability gained by using only what the standard knows; in the end, it's the functionality that matters, not the adherence to a particular standard.

提交回复
热议问题