Skip to content

set of windows (mingw64) build fixes #3090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libs/EXTERNAL/libezgl/include/ezgl/graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#include <functional>
#include <string>
#include <vector>
#ifdef _WIN32
#define _USE_MATH_DEFINES // ensure (non-standard) value of M_PI is brought in from math.h
#endif
Comment on lines +42 to +44
Copy link
Contributor

@AmirhosseinPoolad AmirhosseinPoolad May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libezgl doesn't actually belong to this repository and is a subtree here. The actual repo for it is here:
https://github.com/verilog-to-routing/ezgl

However, we're going to sync up the two repositories really soon so I think it's okay to do the change here. @AlexandreSinger thoughts?

Also if ezgl is compiled with C++20, see below on a way to avoid doing ifdefs.

EDIT: Just checked and it's C++14.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this PR can come in before we change this to a sub-module it should be fine (we can include it with the other changes that need to be brought in); if not, @w0lek would need to raise a PR on the EZGL repo (which we will immediately accept).

I think EZGL is kept on C++14 to ensure that it builds on the school computers for the coarse it is used in (but thats just a guess). C++20 is still technically experimental and some of the features confuse students, so we keep them on C++14 if I recall correctly. I see no issue with this fix for now.

#include <cfloat>
#include <cmath>
#include <algorithm>
Expand Down
61 changes: 0 additions & 61 deletions libs/libvtrutil/src/vtr_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,67 +375,6 @@ char* fgets(char* buf, int max_size, FILE* fp) {
return nullptr;
}

/**
* @brief to get an arbitrary long input line and cut off any
* comment part
*
* the getline function is exaly like the __get_delim function
* in GNU with '\n' delimiter. As a result, to make the function
* behaviour identical for Windows (\r\n) and Linux (\n) compiler
* macros for checking operating systems have been used.
*
* @note user need to take care of the given pointer,
* which will be dynamically allocated by getdelim
*/
char* getline(char*& _lineptr, FILE* _stream) {
int i;
int ch;
size_t _n = 0;
ssize_t nread;

#if defined(__unix__)
nread = getdelim(&_lineptr, &_n, '\n', _stream);
#elif defined(_WIN32)
#define __WIN_NLTK "\r\n"
nread = getdelim(&_lineptr, &_n, __WIN_NLTK, _stream);
#endif

if (nread == -1) {
int errsv = errno;
std::string error_msg;

if (errsv == EINVAL)
error_msg = string_fmt("[%s] Bad arguments (_lineptr is NULL, or _stream is not valid).", strerror(errsv));
else if (errsv == ENOMEM)
error_msg = string_fmt("[%s] Allocation or reallocation of the line buffer failed.", strerror(errsv));
else
/* end of file so it will return null */
return nullptr;

/* getline was unsuccessful, so error */
throw VtrError(string_fmt("Error -- %s\n",
error_msg.c_str()),
__FILE__, __LINE__);
return nullptr;
}

cont = 0; /* line continued? */
file_line_number++; /* global variable */

for (i = 0; i < nread; i++) { /* Keep going until the line finishes */

ch = _lineptr[i];

if (ch == '#') { /* comment */
_lineptr[i] = '\0';
/* skip the rest of the line */
break;
}
}

return (_lineptr);
}

///@brief Returns line number of last opened and read file
int get_file_line_number_of_last_opened_file() {
return file_line_number;
Expand Down
3 changes: 3 additions & 0 deletions vpr/src/draw/draw_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#ifndef NO_GRAPHICS

#include <cstdio>
#ifdef _WIN32
#define _USE_MATH_DEFINES // ensure (non-standard) value of M_PI is brought in from math.h
#endif
Comment on lines +7 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C++20 has added std::numbers::pi (double) and std::numbers::pi_v which should fix this problem and would be cleaner. I'm not sure if ezgl is compiled with C++20 but it can definitely be used here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no objection to compiling ezgl with C++20. The UG machines at U of T use g++12.2, and all g++ C++20 support was in by g++ version 11.

Using std::numbers::pi is fine with me.

#include <cmath>
#include <algorithm>
#include <sstream>
Expand Down