Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

They aren't entirely bad suggestions, but it can be improved somewhat, depending on taste:

>Rule #4: Use only built in #ifdef compiler flags, do not invent your own

Actually you can separate the source code into src/linux src/w32 src/mac -- but that is just my preference.

>Rule #9: Require all programmers to compile on all platforms

No no no -- build has to take no more than a make command. Anything else is just domed to failure.



> Actually you can separate the source code into src/linux src/w32 src/mac -- but that is just my preference.

IMO the author suggests to develop in a single source tree which compiles on every platform for very good reasons, in particular to minimize duplication and being able to update a single method in a single file to work on all platforms. Your suggested multi-directory approach requires to duplicate most os-specific methods and classes. Depending on the situation one or the other approach might be better, but I think the author has a point in many of them.

> No no no -- build has to take no more than a make command. Anything else is just domed to failure.

Building with just a "make" should be fine on Linux, but for anyone who downloads the source code to a Windows/VS or OSX/XCode machine, it's great being able to just open the project in the standard editor and compile it.


Our 'make' vs Visual Studio issue is: to add a new module in Visual Studio you add it to the project. VS automatically getting included in many makefile scenarios. Which causes a common bug: a _WIN32-only module gets built on the wrong platform because the developer forgets to put the module in the makefile exclusion list.

Small matter, easily detected and fixed in the first build, but would be nice to automate somehow.


CMake (or perhaps Scons, but I have no experience with that) might be useful for you. Although going through the motions of writing build scripts for you build system might not be something you want to endure.

In any case, I used CMake in one shop I worked in and it was nice to have the build files all managed in one place. We were able to manage builds for Windows, Linux, Mac, and Solaris.


Oh I didn't mean that you should put all your source code in those folders - only that which is different for each platform, and if that is only one or two methods in each class then that is not a problem as C++ is much more flexible in that regard than C# or Java.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: