|
|
1. <strong>Avoid mixing C headers, functions, and casting</strong> use corresponding C++ equivalent. Example: use ```cmath``` not ```math.h```, ```iostream``` not ```stdio.h```
|
|
|
|
|
|
* _Don't_
|
|
|
``cpp
|
|
|
* _Don't_
|
|
|
```cpp
|
|
|
#include <stdio.h>
|
|
|
#include <math.h>
|
|
|
...
|
|
|
float powerOfTwo = powf( 2.f, 5.f );
|
|
|
printf( "2^5 = %f\n", powerOfTwo );
|
|
|
```
|
|
|
|
|
|
* _Do_
|
|
|
``cpp
|
|
|
```cpp
|
|
|
#include <iostream>
|
|
|
#include <cmath>
|
|
|
...
|
|
|
constexpr float powerOfTwo = powf( 2.f, 5.f );
|
|
|
std::cout << "2^5 = " << powerOfTwo << "\n";
|
|
|
```
|
|
|
|
|
|
2. <strong>Exception for using C headers/functions:</strong>
|
|
|
* C++ API is deprecated or not fully supported libraries ( _e.g._ MPI, CUDA_C, PETSc )
|
... | ... | |