@@ -7,6 +7,9 @@ pub fn build(b: *std.Build) void {
77 // Standard optimization options
88 const optimize = b .standardOptimizeOption (.{});
99
10+ // Determine C standard based on platform
11+ const c_std = if (target .result .os .tag == .linux ) "-std=gnu11" else "-std=c11" ;
12+
1013 // Build options
1114 const build_shared = b .option (bool , "shared" , "Build shared library" ) orelse false ;
1215 const build_examples = b .option (bool , "examples" , "Build example programs" ) orelse true ;
@@ -65,7 +68,7 @@ pub fn build(b: *std.Build) void {
6568 .flags = &.{
6669 "-Wall" ,
6770 "-Wextra" ,
68- "-std=c11" ,
71+ c_std ,
6972 "-DHAVE_CONFIG_H" ,
7073 },
7174 });
@@ -135,7 +138,7 @@ pub fn build(b: *std.Build) void {
135138 "-Wall" ,
136139 "-Wextra" ,
137140 "-pedantic" ,
138- "-std=c11" ,
141+ c_std ,
139142 },
140143 });
141144
@@ -213,6 +216,7 @@ pub fn build(b: *std.Build) void {
213216 opt : std.builtin.OptimizeMode ,
214217 colyseus_lib : * std.Build.Step.Compile ,
215218 wslay_version_header : * std.Build.Step.ConfigHeader ,
219+ c_standard : []const u8 ,
216220 ) void {
217221 const example_module = builder .createModule (.{
218222 .target = tgt ,
@@ -230,7 +234,7 @@ pub fn build(b: *std.Build) void {
230234 .flags = &.{
231235 "-Wall" ,
232236 "-Wextra" ,
233- "-std=c11" ,
237+ c_standard ,
234238 },
235239 });
236240
@@ -261,14 +265,14 @@ pub fn build(b: *std.Build) void {
261265 .source_file = "examples/simple_example.c" ,
262266 .run_step_name = "run-example" ,
263267 .run_step_desc = "Run the simple example" ,
264- }, target , optimize , colyseus , wslay_version_h );
268+ }, target , optimize , colyseus , wslay_version_h , c_std );
265269
266270 buildExample (b , .{
267271 .name = "auth_example" ,
268272 .source_file = "examples/auth_example.c" ,
269273 .run_step_name = "run-auth-example" ,
270274 .run_step_desc = "Run the auth example" ,
271- }, target , optimize , colyseus , wslay_version_h );
275+ }, target , optimize , colyseus , wslay_version_h , c_std );
272276 }
273277
274278 // ========================================================================
0 commit comments