# OpenPBS's C++ Coding Standards

**URL:** <https://community.openpbs.org/t/openpbss-c-coding-standards/2315>\
**Category:** Developers\
**Created:** [October 8, 2020, 12:43am UTC](https://community.openpbs.org/t/openpbss-c-coding-standards/2315 "2020-10-08T00:43:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vstumpf](https://avatars.discourse-cdn.com/v4/letter/v/dbc845/32.png) [@vstumpf](https://community.openpbs.org/u/vstumpf)\
**Post date:** [October 8, 2020, 12:43am UTC](https://community.openpbs.org/t/openpbss-c-coding-standards/2315/1 "2020-10-08T00:43:05Z")

</div>

Hi everyone

Due to the conversion of the scheduler to C++, we would like to conform to some Coding Standards, like we have for [C and Python](https://openpbs.atlassian.net/wiki/spaces/DG/pages/1481670667/PBS+Pro+Coding+Standards).

The proposed standards are [here](https://openpbs.atlassian.net/wiki/spaces/PD/pages/2155347969/C+Coding+Standards).

Thanks,  
Vincent

---

<div class="post-metadata">

**Author:** ![hirenvadalia](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/hirenvadalia/32/19_2.png) [@hirenvadalia](https://community.openpbs.org/u/hirenvadalia)\
**Post date:** [October 8, 2020, 5:17am UTC](https://community.openpbs.org/t/openpbss-c-coding-standards/2315/2 "2020-10-08T05:17:18Z")

</div>

@vstumpf I have one comment and one question for “Brace Style”:

Comment: In single line if-else, we have “good” (where we keep brace) and “Also good” (where we don’t keep brace). I would suggest keep only one of them not both. As keeping both in standards creates lots of questions and confusion during code review. Also keeping both, will have mix style for single line if-else in code as some developers likes to keep them and some (like me 🙂) don’t.

Question:  
About function definition: As per current standards we use below format, are you proposing change in that? If yes then any reason to do that?

```auto
int
add(int x, int y)
{

```

---

<div class="post-metadata">

**Author:** ![vstumpf](https://avatars.discourse-cdn.com/v4/letter/v/dbc845/32.png) [@vstumpf](https://community.openpbs.org/u/vstumpf)\
**Post date:** [October 8, 2020, 9:34pm UTC](https://community.openpbs.org/t/openpbss-c-coding-standards/2315/3 "2020-10-08T21:34:28Z")

</div>

You bring up a good point, since we already have a C standard, and we still have C code, we should follow that standard as much as possible.

I’ve removed the conflicting standards to only include C++ specific changes.

---

<div class="post-metadata">

**Author:** ![hirenvadalia](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/hirenvadalia/32/19_2.png) [@hirenvadalia](https://community.openpbs.org/u/hirenvadalia)\
**Post date:** [October 9, 2020, 5:19am UTC](https://community.openpbs.org/t/openpbss-c-coding-standards/2315/4 "2020-10-09T05:19:55Z")

</div>

Thanks @vstumpf, now its look good.
