Skip to content

Commit

Permalink
Fix MSVC Warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
axionbuster committed Mar 10, 2024
1 parent e25cfd2 commit 441361e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions demo/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ namespace env {

std::optional<std::string> get(char const *sv) {
#ifdef _WIN32
char *s;
size_t n;
char *s{};
size_t n{};
// On Windows, _dupenv_s is the Microsoft-recommended way of reading an
// environment variable. When the variable isn't found, the error (e) is 0 and
// the count (n) is also 0 (also, the buffer [s] is set to NULL).
if (auto e = _dupenv_s(&s, &n, sv); e || !n)
if (auto e = _dupenv_s(&s, &n, sv); e || !s)
return {};
std::string t{s, n};
// According to Microsoft, the buffer s must be freed using a call to `free`.
Expand Down
12 changes: 9 additions & 3 deletions demo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <cmath>
#include <complex>
#include <cstdlib>
#include <halton.h>
#include <random>
#include <raylib.h>
#include <stdexcept>
Expand All @@ -15,9 +14,13 @@
#include "Table.h"
#include "env.h"
#include "user.h"
#include <numbers>
#include <utility>

using namespace phy;

namespace main_program {

/// Constants controlling the program.
struct Constants {
/// Inclusive upper limit of the number of particles.
Expand Down Expand Up @@ -211,7 +214,7 @@ struct State {
EndDrawing();
}

User make_user() {
User make_user() const {
User u;
if (constants.flags.galaxies)
u.control.demo = false;
Expand All @@ -222,10 +225,13 @@ struct State {
return constants.flags.galaxies ? galaxies(constants) : figure8();
}
} state;
} // namespace main_program

void do_loop() { state.loop(); }
void do_loop() { main_program::state.loop(); }

static int do_main() {
using namespace main_program;

SetConfigFlags(FLAG_WINDOW_RESIZABLE);
InitWindow(600, 600, "Grass Gravity Simulation");

Expand Down

0 comments on commit 441361e

Please sign in to comment.