OpenPilot GCS Coding Guide





OpenPilot GCS Coding Guide

GCS Coding style

If you would like to contribute to the GCS – and you are most certainly welcome to! -, you should follow the GCS coding style, which follows the Qt Style found here:

http://developer.qt.nokia.com/wiki/Qt_Coding_Style

GCS coding rules

Multiplatform coding guidelines and tips

GCS is a multiplatform application: it works on MacOS, Linux and Windows. When you write code on one platform, please make sure it will not break other platforms, or your commit will not be accepted.

  • Always use slash ‘/’, to separate directories, for instance in #include statements. Back-slash are common on Windows, but Linux doesn’t understand them. When it comes path separators in applicative code, you should use Qt abstraction (see QDir) and, again, only use slashes, not backslashes.
  • Windows needs a compiler directive to import/export functions to a DLL, that’s why we have XXX_EXPORT in front of classes. Linux doesn’t need that so it’s easy to forget them. This is absolutely necessary when writing plugins: each function contained in a plugin, and which should be available to other plugins has to have that declaration in front of its class.

Various tips

Using -l$$qtLibraryTarget in .pri files is a bad practice. This macro is used to define the target name to export, but behaves differently depending on the context from which it is called.

If a non-lib calls this macro, it does not append the debug flag. However in debug mode all our plugins and utils are built as debug so the wrong ones are included.

This means any time someone adds a new include .pri to app.pro it will break windows and mac (linux ignores this macro).

Comments

So empty here ... leave a comment!

发表评论

电子邮件地址不会被公开。 必填项已用*标注

Sidebar