Discussion Locked

Achieve platform independence

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
The Nov. 18 C++ TechMail suggests that a unix_or_win32_name macro can help developers write platform-independent code. Tell us what you think; will it help your application development?

3 replies

by kevlin

The proposed macro is unnecessary for the specific example used in the article, that of determining the correct path separator to be used when opening a file. Win32 has always understood the use of '/' as a directory separator, so determining whether or not to use '/' or '\\' in this context is superfluous.

As a more general aside, the unix_or_win32_name violates a de facto standard (and well-reasoned) C naming convention: name macros in uppercase.

Kevlin

by richard l.

While the article isn't profound and may have a few blemishes, it's neverthess nice to have some of the details worked out for those of us who in the future may have to deal with cross-platform coding.

While the issue of forward vs backward slashes are superfluous, it is still necessary to distinguish between Uinx and Windows for the expression of fully qualifed paths, as the author has done.

by john torjo

Hi Kevlin,

The truth is I did not know that Win32 allows for '/' as well, so you're right.

You are right about the second issue as well. But it's easy to re-write it in uppercase.

Anyway, I think the macro itself is of very good use, and I have used it quite a lot recently.

Thanks for the comments.

Best,
John

This discussion is closed to new replies.