Hi, J Doe wrote on Tue, Jul 04, 2017 at 12:02:42AM -0400:
> I would like to target OpenBSD with some networking code I am > writing in C++ (again, in user land, not kernel networking code). > I'd like to follow the OpenBSD way The OpenBSD way is to write userland network daemons in C, not in C++. > and make use of the safer family of C functions and best practices > that OpenBSD makes use of. There are no OpenBSD best practices for C++. Most developers - certainly not all - dislike C++ as overengineered, overcomplicated, slow to compile, hard to debug, and for its utterly inconsistent design and excessively heavy tool chain. While nobody denies that there may be use cases for C++, even those who like the language do not use it when writing software for OpenBSD. Code written in C++ (except, maybe, if part of a C++ compiler or closely related tools) is unlikely to be accepted in the base system, and each time something in base that is written in C++ gets replaced by something that is not, i hear cheering. > I was thinking the best way to get started would be to spend two > to three months reading No. Certainly not. By all means, do read code, that is very important, but do it in parallel to getting hands-on experience by fixing bugs (and maybe implementing very simple features, which is *much* harder, in particular because new features are often rejected - it is not easy for beginners to figure out which new feature will be considered useful and which won't). Also, don't stop reading code after a few months; never stop doing that, at least not before you die. > there might be a man page that codifies best practices for OpenBSD > development - not the coding style but more of an overview of best > practices - such as, "Prefer OpenBSD specific functionXYZ() as > opposed to strncpy()" (a contrived example but something in that > respect). Such a manpage definitely doesn't exist, or i would have heard about it. If best practice recommendations exist with respect to a specific function, they are often explained in the manual page of that function. For example, i added a notice to prefer getline(3) to the top of the fgetln(3) manual just a few days ago. Such recommendations are sometimes placed at the top of the DESCRIPTION, sometimes in EXAMPLES or CAVEATS, and may also appear in other places. Sometimes, they are missing completely. For example, to my surprise, strcpy(3) only mentions strlcpy(3) below SEE ALSO. > Separate from the possible man page, are there any relatively > up-to-date examples that developers have been using to learn best > practices for writing software for OpenBSD? No. Developers are learning by doing, and by advice from fellow developers which they receive when posting their patches for review. Yours, Ingo