Site Tools


The IoTivity Coding Standards provide guidelines for how to write code within the IoTivity project. Code committed to the IoTivity project should follow the standards where appropriate. No coding standard can determine what is best in every situation, however developers deviating from the standard should be able to justify why the standard is not applicable.

IoTivity builds and runs on several different platforms using different languages. Each language has its own language standard to better follow the idioms and conventions developers using that language expect.


IoTivity C++ code runs on all platforms. The coding standard is divided into syntactic and semantic parts. The syntactic guidelines provide a clean consistent look for the code. The semantic parts are intended to be advice for writing safe and robust code. The current copy is available on the IoTivity C++ Coding Standards page.

In addition, developers are encouraged to read the best practices in C++ Coding Standards, Sutter & Alexandrescu (also available electronically Safari Subscription, which is included with ACM membership and available through many corporate digital library subscriptions).

Configuring Eclipse

To configure Eclipse to automatically follow the IoTivity style guidelines:

  1. On the Menu bar go to Window > Preferences
  2. In the left pane click C/C++ > Code Style > Formatter
  3. On the right pane click Import button
  4. Choose iotivity_cpp_style.xml from iotivity/tools/style/iotivity_cpp_style.xml
  5. Click Apply

Configuring Visual Studio

To configure Visual Studio to automatically follow the IoTivity style guidelines:

  1. Open Visual Studio. Click Tools on the menu bar. Then choose Options
  2. On the left pane of the Options dialog click “AStyle Formatter”
  3. In the right pane click the Export/Import tab.
  4. Next hit the Import button to import the file iotivity\tools\style\iotivity_cpp_astyle.cfg

Configuring Emacs

Tune your .emacs with those changes :

(setq-default indent-tabs-mode nil)

Configuring Atom

A formatter that uses astyle in Atom is available. Install formatter and formatter-astyle from your settings view. You need to have astyle installed in the system as well. To finish the setup, create an .astylrc in the project root based the settings from tools/style/ - leave out the shell-style syntax, and the recursive option.

Bulk C++ Formatting

These instructions describe how to reformat all of the C++ code using the Artistic Style tool.

  1. Install Artistic Style using the instructions from (note Linux distributions probably already have astyle in their package repository)
  2. Run ${IOTIVITY}/tools/style/ in the top-level directory containing files to be reformatted, where ${IOTIVITY} is the path to the iotivity repository. The script runs the formatter on all .cpp and .h files in the current directory and all subdirectories, recursively.
  3. The formatting process will create backup copies of the original file. All back up files have the .orig extension. To move the *.orig files run ${IOTIVITY}/tools/style/ The script places all of the .orig file in the astyle_backup folder.


IoTivity uses the Android Java Coding Standard for Java code.

Configuring Eclipse

To configure the Eclipse IDE to automatically follow the IoTivity style guidelines, please do the following:

  1. On the Menu bar go to Window > Preferences
  2. In the left pane click Java > Code Style > Formatter
  3. On the right pane click Import button
  4. Choose ccf_cpp_style.xml from iotivity/tools/style/iotivity_java_style.xml
  5. Apply

iOS Objective-C



Informal: All of the scons build scripts are in Python. This includes SConstruct, SConscript and *.scons files. At this time, the project has not formally adopted a coding standard for these files, so the use of Python's own style guid PEP8 is only a recommendation. Pertinent suggestions include 4-space indents, no tabs, single spaces surrounding operators ( = == + and so on); no spaces around = sign for keyword arguments. There are code formatting tools that will provide PEP8 compliance.

iotivity_coding_standards.txt · Last modified: 2018/01/15 13:53 by mwichmann