Skip to content

Commit ffab1cb

Browse files
authored
Removed C++ warnings and unified C/C++ warnings flags (#986)
1 parent 7acfce9 commit ffab1cb

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

SConstruct

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ for language, tools in languages_to_import.items():
6060

6161
Export('env')
6262

63-
env['CFLAGS'] = '-Wall -Wextra -Werror'
64-
env['CXXFLAGS'] = '-std=c++17'
63+
env['CCFLAGS'] = '-Wall -Wextra -Werror -pedantic'
64+
env['CFLAGS'] = '-std=gnu99'
65+
env['CXXFLAGS'] = '-std=c++17 -Wold-style-cast'
6566
env['ASFLAGS'] = '--64'
6667
env['COCONUTFLAGS'] = '--target 3.8'
6768

contents/gaussian_elimination/code/cpp/gaussian_elimination.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ std::vector<double> backSubs(const std::vector<std::vector<double> > &eqns) {
7373

7474

7575
void printMatrix(const std::vector<std::vector<double> > &matrix) {
76-
for (int row = 0; row < matrix.size(); row++) {
76+
for (std::size_t row = 0; row < matrix.size(); row++) {
7777
std::cout << "[";
7878

79-
for (int col = 0; col < matrix[row].size() - 1; col++)
79+
for (std::size_t col = 0; col < matrix[row].size() - 1; col++)
8080
std::cout << std::setw(8) << std::fixed << std::setprecision(3)
8181
<< matrix[row][col];
8282

contents/monte_carlo_integration/code/cpp/monte_carlo.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ double monte_carlo_pi(unsigned samples) {
3737
}
3838

3939
int main() {
40-
unsigned samples;
41-
4240
double pi_estimate = monte_carlo_pi(10000000);
4341
std::cout << "Pi = " << pi_estimate << '\n';
4442
std::cout << "Percent error is: " << 100 * std::abs(pi_estimate - PI) / PI << " %\n";

contents/split-operator_method/code/cpp/split_op.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void fft(vector_complex &x, bool inverse) {
9797
}
9898

9999
void split_op(Params &par, Operators &opr) {
100-
double density[opr.size];
100+
auto density = std::vector<double>(opr.size, 0);
101101

102102
for (size_t i = 0; i < par.timesteps; ++i) {
103103
for (size_t j = 0; j < opr.size; ++j) {
@@ -142,7 +142,7 @@ void split_op(Params &par, Operators &opr) {
142142
std::ofstream fstream = std::ofstream(filename_stream.str());
143143

144144
if (fstream) {
145-
for (int i = 0; i < opr.size; ++i) {
145+
for (std::size_t i = 0; i < opr.size; ++i) {
146146
std::stringstream data_stream;
147147

148148
data_stream << i << "\t" << density[i] << "\t" << real(opr.v[i]) << "\n";

0 commit comments

Comments
 (0)