(winnie) Fix struct stat redefinition - reorder includes#3068
Conversation
|
No actionable comments were generated in the recent review. 🎉 WalkthroughMove of include Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes a Windows MinGW compilation error caused by incorrect include order in report_messages.cpp. On MinGW, C++ standard library headers like <sstream> must be included AFTER PostgreSQL headers to prevent struct stat redefinition conflicts between MinGW's <sys/stat.h> and PostgreSQL's win32_port.h.
Changes:
- Reordered includes in
report_messages.cppto place PostgreSQL C headers before C++ standard library headers - Moved
#include "cpp_common/report_messages.hpp"after#include <sstream>to maintain proper ordering
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hello @cvvergara , |
Fixes #3067 .
On Windows (MinGW), C++ headers like
<sstream>must be included AFTER PostgreSQL headers to avoidstruct statredefinition errors.The Problem
The include order in
report_messages.cppwas:#include "cpp_common/report_messages.hpp" // includes
extern "C" {
#include "c_common/postgres_connection.h" // PostgreSQL AFTER = broken
}
This causes MinGW's <sys/stat.h> to define struct stat first, then PostgreSQL's win32_port.h tries to redefine it → compilation error.
The Fix
Reorder includes so PostgreSQL headers come first:
extern "C" {
#include "c_common/postgres_connection.h" // PostgreSQL FIRST
#include "c_common/e_report.h"
}
#include
<sstream>// C++ headers AFTER#include "cpp_common/report_messages.hpp" // Project headers AFTER
@pgRouting/admins
Summary by CodeRabbit