Skip to content

Commit 42594de

Browse files
Termux Userclaude
andcommitted
fix: remove duplicate FormatterOptions definitions from formatter.cpp
defaults() and fromFile() were defined in both formatter.cpp and style_config.cpp. MSVC linker is strict about multiply-defined symbols (LNK2005). Keep canonical definitions in style_config.cpp only. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5ae1fea commit 42594de

1 file changed

Lines changed: 2 additions & 98 deletions

File tree

src/formatter/formatter.cpp

Lines changed: 2 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -51,104 +51,8 @@ static std::string unaryOpToString(UnaryOp op) {
5151
}
5252
}
5353

54-
// ============================================================================
55-
// FormatterOptions Implementation
56-
// ============================================================================
57-
58-
FormatterOptions FormatterOptions::defaults() {
59-
return FormatterOptions{};
60-
}
61-
62-
FormatterOptions FormatterOptions::fromFile(const std::string& path) {
63-
FormatterOptions opts = defaults(); // Start with defaults
64-
65-
try {
66-
auto config = toml::parse_file(path);
67-
68-
// [style] section
69-
if (config.contains("style")) {
70-
auto& style = *config["style"].as_table();
71-
if (style["indent_width"]) {
72-
opts.indent_width = style["indent_width"].value_or(4);
73-
}
74-
if (style["max_line_length"]) {
75-
opts.max_line_length = style["max_line_length"].value_or(100);
76-
}
77-
if (style["semicolons"]) {
78-
std::string semicolon_str = style["semicolons"].value_or("never");
79-
if (semicolon_str == "always") opts.semicolons = SemicolonStyle::Always;
80-
else if (semicolon_str == "as-needed") opts.semicolons = SemicolonStyle::AsNeeded;
81-
else opts.semicolons = SemicolonStyle::Never;
82-
}
83-
if (style["trailing_commas"]) {
84-
opts.trailing_commas = style["trailing_commas"].value_or(true);
85-
}
86-
}
87-
88-
// [braces] section
89-
if (config.contains("braces")) {
90-
auto& braces = *config["braces"].as_table();
91-
if (braces["function_brace_style"]) {
92-
std::string style = braces["function_brace_style"].value_or("same_line");
93-
opts.function_brace_style = (style == "next_line") ? BraceStyle::NextLine : BraceStyle::SameLine;
94-
}
95-
if (braces["control_flow_brace_style"]) {
96-
std::string style = braces["control_flow_brace_style"].value_or("same_line");
97-
opts.control_flow_brace_style = (style == "next_line") ? BraceStyle::NextLine : BraceStyle::SameLine;
98-
}
99-
}
100-
101-
// [spacing] section
102-
if (config.contains("spacing")) {
103-
auto& spacing = *config["spacing"].as_table();
104-
if (spacing["blank_lines_between_declarations"]) {
105-
opts.blank_lines_between_declarations = spacing["blank_lines_between_declarations"].value_or(1);
106-
}
107-
if (spacing["blank_lines_between_sections"]) {
108-
opts.blank_lines_between_sections = spacing["blank_lines_between_sections"].value_or(2);
109-
}
110-
if (spacing["space_before_function_paren"]) {
111-
opts.space_before_function_paren = spacing["space_before_function_paren"].value_or(false);
112-
}
113-
if (spacing["space_in_empty_parens"]) {
114-
opts.space_in_empty_parens = spacing["space_in_empty_parens"].value_or(false);
115-
}
116-
}
117-
118-
// [wrapping] section
119-
if (config.contains("wrapping")) {
120-
auto& wrapping = *config["wrapping"].as_table();
121-
if (wrapping["wrap_function_params"]) {
122-
std::string style = wrapping["wrap_function_params"].value_or("auto");
123-
if (style == "always") opts.wrap_function_params = WrappingStyle::Always;
124-
else if (style == "never") opts.wrap_function_params = WrappingStyle::Never;
125-
else opts.wrap_function_params = WrappingStyle::Auto;
126-
}
127-
if (wrapping["wrap_struct_fields"]) {
128-
std::string style = wrapping["wrap_struct_fields"].value_or("auto");
129-
if (style == "always") opts.wrap_struct_fields = WrappingStyle::Always;
130-
else if (style == "never") opts.wrap_struct_fields = WrappingStyle::Never;
131-
else opts.wrap_struct_fields = WrappingStyle::Auto;
132-
}
133-
if (wrapping["wrap_array_elements"]) {
134-
std::string style = wrapping["wrap_array_elements"].value_or("auto");
135-
if (style == "always") opts.wrap_array_elements = WrappingStyle::Always;
136-
else if (style == "never") opts.wrap_array_elements = WrappingStyle::Never;
137-
else opts.wrap_array_elements = WrappingStyle::Auto;
138-
}
139-
if (wrapping["align_wrapped_params"]) {
140-
opts.align_wrapped_params = wrapping["align_wrapped_params"].value_or(true);
141-
}
142-
}
143-
144-
} catch (const toml::parse_error& err) {
145-
// If config file is invalid, fall back to defaults
146-
fmt::print(stderr, "Warning: Failed to parse {}: {}\n", path, err.what());
147-
fmt::print(stderr, "Using default formatting options.\n");
148-
}
149-
150-
return opts;
151-
}
54+
// FormatterOptions::defaults() and FormatterOptions::fromFile() are
55+
// defined in style_config.cpp to avoid duplicate symbol errors.
15256

15357
// ============================================================================
15458
// FormatterContext Implementation

0 commit comments

Comments
 (0)