Skip to content

Commit

Permalink
Removed C++ warnings and unified C/C++ warnings flags (algorithm-arch…
Browse files Browse the repository at this point in the history
  • Loading branch information
Amaras authored Jan 17, 2022
1 parent 7acfce9 commit ffab1cb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
5 changes: 3 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ for language, tools in languages_to_import.items():

Export('env')

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ std::vector<double> backSubs(const std::vector<std::vector<double> > &eqns) {


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

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

Expand Down
2 changes: 0 additions & 2 deletions contents/monte_carlo_integration/code/cpp/monte_carlo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ double monte_carlo_pi(unsigned samples) {
}

int main() {
unsigned samples;

double pi_estimate = monte_carlo_pi(10000000);
std::cout << "Pi = " << pi_estimate << '\n';
std::cout << "Percent error is: " << 100 * std::abs(pi_estimate - PI) / PI << " %\n";
Expand Down
4 changes: 2 additions & 2 deletions contents/split-operator_method/code/cpp/split_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void fft(vector_complex &x, bool inverse) {
}

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

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

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

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

0 comments on commit ffab1cb

Please sign in to comment.