Skip to content

Commit 0a886e6

Browse files
committed
Fix MSVC compiler warnings and platform-specific configuration
- Fix MSVC /W3 overriding warnings by using platform-specific flags - Add explicit /W4 flag for Windows builds - Fix size_t to int conversion warning in examples/basic_usage.cpp - Add platform-specific compiler flag configuration to avoid conflicts - Improve xmake.lua with better Windows/Linux compatibility
1 parent 2240082 commit 0a886e6

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

examples/basic_usage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ void demonstrate_eda_design_rules() {
318318
for (size_t i = 0; i < eda_components.size(); ++i) {
319319
auto sharp_angles = eda_components[i].get_sharp_angles(process.sharp_angle_limit);
320320
if (!sharp_angles.empty()) {
321-
violations += sharp_angles.size();
321+
violations += static_cast<int>(sharp_angles.size());
322322
std::cout << " " << component_names[i] << ": " << sharp_angles.size()
323323
<< " sharp angle violations" << std::endl;
324324
}

xmake.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,21 @@ set_languages("c++17")
77

88
-- Configure compiler options
99
add_rules("mode.debug", "mode.release")
10-
add_cxxflags("-Wall", "-Wextra", "-Wpedantic")
10+
11+
-- Platform-specific compiler flags to avoid MSVC warnings
12+
if is_plat("windows") then
13+
-- Use /W4 for MSVC instead of conflicting with default /W3
14+
add_cxxflags("/W4")
15+
if is_mode("release") then
16+
add_cxxflags("/O2")
17+
end
18+
else
19+
-- GCC/Clang flags for Linux/macOS
20+
add_cxxflags("-Wall", "-Wextra")
21+
-- Only add pedantic for non-MSVC compilers
22+
set_policy("check.auto_ignore_flags", false)
23+
add_cxxflags("-Wpedantic", {force = true})
24+
end
1125

1226
if is_mode("debug") then
1327
add_defines("DEBUG")

0 commit comments

Comments
 (0)