From a18051fdd91f634dbb8f53be91b800bbf92b193f Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Sun, 26 Jul 2026 06:10:19 -0700 Subject: [PATCH] Fix various warnings when building in VC2022 (#6020) --- examples/audio/audio_raw_stream.c | 10 +++--- examples/audio/audio_stream_callback.c | 32 +++++++++---------- examples/core/core_highdpi_testbed.c | 2 +- .../models/models_animation_blend_custom.c | 4 +-- examples/models/models_animation_blending.c | 2 +- examples/models/models_basic_voxel.c | 2 +- examples/models/models_bone_socket.c | 2 +- examples/models/models_loading_m3d.c | 2 +- examples/textures/textures_clipboard_image.c | 4 +-- .../textures/textures_framebuffer_rendering.c | 2 +- .../examples/shapes_clock_of_clocks.vcxproj | 16 +++++----- .../textures_cellular_automata.vcxproj | 16 +++++----- 12 files changed, 47 insertions(+), 47 deletions(-) diff --git a/examples/audio/audio_raw_stream.c b/examples/audio/audio_raw_stream.c index 1978511ed..2a73c4cf4 100644 --- a/examples/audio/audio_raw_stream.c +++ b/examples/audio/audio_raw_stream.c @@ -90,7 +90,7 @@ int main(void) for (int i = 0; i < BUFFER_SIZE; i++) { int wavelength = SAMPLE_RATE/sineFrequency; - buffer[i] = sin(2*PI*sineIndex/wavelength); + buffer[i] = sinf(2*PI*sineIndex/wavelength); sineIndex++; if (sineIndex >= wavelength) @@ -116,8 +116,8 @@ int main(void) DrawText("Up/down to change frequency", 10, 10, 20, DARKGRAY); DrawText("Left/right to pan", 10, 30, 20, DARKGRAY); - int windowStart = (GetTime() - sineStartTime)*SAMPLE_RATE; - int windowSize = 0.1f*SAMPLE_RATE; + int windowStart = (int)((GetTime() - sineStartTime)*SAMPLE_RATE); + int windowSize = SAMPLE_RATE/10; int wavelength = SAMPLE_RATE/sineFrequency; // Draw a sine wave with the same frequency as the one being sent to the audio stream @@ -125,8 +125,8 @@ int main(void) { int t0 = windowStart + i*windowSize/screenWidth; int t1 = windowStart + (i + 1)*windowSize/screenWidth; - Vector2 startPos = { i, 250 + 50*sin(2*PI*t0/wavelength) }; - Vector2 endPos = { i + 1, 250 + 50*sin(2*PI*t1/wavelength) }; + Vector2 startPos = { (float)i, 250 + 50*sinf(2*PI*t0/wavelength) }; + Vector2 endPos = { (float)i + 1, 250 + 50*sinf(2*PI*t1/wavelength) }; DrawLineV(startPos, endPos, RED); } diff --git a/examples/audio/audio_stream_callback.c b/examples/audio/audio_stream_callback.c index a033571d1..59e1edac9 100644 --- a/examples/audio/audio_stream_callback.c +++ b/examples/audio/audio_stream_callback.c @@ -133,8 +133,8 @@ int main(void) // Draw the last 10 ms of uploaded audio for (int i = 0; i < screenWidth; i++) { - Vector2 startPos = { i, 250 - 50*buffer[SAMPLE_RATE - SAMPLE_RATE/100 + i*SAMPLE_RATE/100/screenWidth] }; - Vector2 endPos = { i + 1, 250 - 50*buffer[SAMPLE_RATE - SAMPLE_RATE/100 + (i + 1)*SAMPLE_RATE/100/screenWidth] }; + Vector2 startPos = {(float)i, 250 - 50*buffer[SAMPLE_RATE - SAMPLE_RATE/100 + i*SAMPLE_RATE/100/screenWidth] }; + Vector2 endPos = { (float)(i + 1), 250 - 50*buffer[SAMPLE_RATE - SAMPLE_RATE/100 + (i + 1)*SAMPLE_RATE/100/screenWidth] }; DrawLineV(startPos, endPos, RED); } @@ -161,9 +161,9 @@ static void SineCallback(void *framesOut, unsigned int frameCount) int wavelength = SAMPLE_RATE/waveFrequency; // Synthesize the sine wave - for (int i = 0; i < frameCount; i++) + for (unsigned int i = 0; i < frameCount; i++) { - ((float *)framesOut)[i] = sin(2*PI*waveIndex/wavelength); + ((float *)framesOut)[i] = sinf(2*PI*waveIndex/wavelength); waveIndex++; @@ -175,8 +175,8 @@ static void SineCallback(void *framesOut, unsigned int frameCount) } // Save the synthesized samples for later drawing - for (int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount]; - for (int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i]; + for (unsigned int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount]; + for (unsigned int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i]; } static void SquareCallback(void *framesOut, unsigned int frameCount) @@ -184,9 +184,9 @@ static void SquareCallback(void *framesOut, unsigned int frameCount) int wavelength = SAMPLE_RATE/waveFrequency; // Synthesize the square wave - for (int i = 0; i < frameCount; i++) + for (unsigned int i = 0; i < frameCount; i++) { - ((float *)framesOut)[i] = (waveIndex < wavelength/2)? 1 : -1; + ((float *)framesOut)[i] = (waveIndex < wavelength/2)? 1.0f : -1.0f; waveIndex++; if (waveIndex >= wavelength) @@ -197,8 +197,8 @@ static void SquareCallback(void *framesOut, unsigned int frameCount) } // Save the synthesized samples for later drawing - for (int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount]; - for (int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i]; + for (unsigned int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount]; + for (unsigned int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i]; } static void TriangleCallback(void *framesOut, unsigned int frameCount) @@ -206,7 +206,7 @@ static void TriangleCallback(void *framesOut, unsigned int frameCount) int wavelength = SAMPLE_RATE/waveFrequency; // Synthesize the triangle wave - for (int i = 0; i < frameCount; i++) + for (unsigned int i = 0; i < frameCount; i++) { ((float *)framesOut)[i] = (waveIndex < wavelength/2)? (-1 + 2.0f*waveIndex/(wavelength/2)) : (1 - 2.0f*(waveIndex - wavelength/2)/(wavelength/2)); waveIndex++; @@ -219,8 +219,8 @@ static void TriangleCallback(void *framesOut, unsigned int frameCount) } // Save the synthesized samples for later drawing - for (int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount]; - for (int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i]; + for (unsigned int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount]; + for (unsigned int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i]; } static void SawtoothCallback(void *framesOut, unsigned int frameCount) @@ -228,7 +228,7 @@ static void SawtoothCallback(void *framesOut, unsigned int frameCount) int wavelength = SAMPLE_RATE/waveFrequency; // Synthesize the sawtooth wave - for (int i = 0; i < frameCount; i++) + for (unsigned int i = 0; i < frameCount; i++) { ((float *)framesOut)[i] = -1 + 2.0f*waveIndex/wavelength; waveIndex++; @@ -241,6 +241,6 @@ static void SawtoothCallback(void *framesOut, unsigned int frameCount) } // Save the synthesized samples for later drawing - for (int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount]; - for (int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i]; + for (unsigned int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount]; + for (unsigned int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float*)framesOut)[i]; } diff --git a/examples/core/core_highdpi_testbed.c b/examples/core/core_highdpi_testbed.c index 246ef4b42..16c5d2b4d 100644 --- a/examples/core/core_highdpi_testbed.c +++ b/examples/core/core_highdpi_testbed.c @@ -88,7 +88,7 @@ int main(void) DrawCircleV(GetMousePosition(), 20, MAROON); DrawRectangleRec((Rectangle) { mousePos.x - 25, mousePos.y, 50, 2 }, BLACK); DrawRectangleRec((Rectangle) { mousePos.x, mousePos.y - 25, 2, 50 }, BLACK); - DrawText(TextFormat("[%i,%i]", GetMouseX(), GetMouseY()), mousePos.x - 44, + DrawText(TextFormat("[%i,%i]", GetMouseX(), GetMouseY()), (int)mousePos.x - 44, (mousePos.y > GetScreenHeight() - 60)? (int)mousePos.y - 46 : (int)mousePos.y + 30, 20, BLACK); EndDrawing(); diff --git a/examples/models/models_animation_blend_custom.c b/examples/models/models_animation_blend_custom.c index 018012e9b..6687609c2 100644 --- a/examples/models/models_animation_blend_custom.c +++ b/examples/models/models_animation_blend_custom.c @@ -212,12 +212,12 @@ static void UpdateModelAnimationBones(Model *model, ModelAnimation *anim0, int f if (frame1 < 0) frame1 = 0; // Get bone count (use minimum of all to be safe) - int boneCount = model->skeleton.boneCount; + unsigned int boneCount = model->skeleton.boneCount; if (anim0->boneCount < boneCount) boneCount = anim0->boneCount; if (anim1->boneCount < boneCount) boneCount = anim1->boneCount; // Blend each bone - for (int boneIndex = 0; boneIndex < boneCount; boneIndex++) + for (unsigned int boneIndex = 0; boneIndex < boneCount; boneIndex++) { // Determine blend factor for this bone float boneBlendFactor = blend; diff --git a/examples/models/models_animation_blending.c b/examples/models/models_animation_blending.c index 3fc43711e..078e3978b 100644 --- a/examples/models/models_animation_blending.c +++ b/examples/models/models_animation_blending.c @@ -252,7 +252,7 @@ int main(void) GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER); GuiSetStyle(DEFAULT, TEXT_SIZE, GuiGetFont().baseSize*2); - GuiLabel((Rectangle){ 0, GetScreenHeight() - 100.0f, GetScreenWidth(), 40 }, "PRESS SPACE to START BLENDING"); + GuiLabel((Rectangle){ 0, GetScreenHeight() - 100.0f, (float)GetScreenWidth(), 40 }, "PRESS SPACE to START BLENDING"); GuiSetStyle(DEFAULT, TEXT_SIZE, GuiGetFont().baseSize); GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT); diff --git a/examples/models/models_basic_voxel.c b/examples/models/models_basic_voxel.c index 8d8b6b0c7..7f90396af 100644 --- a/examples/models/models_basic_voxel.c +++ b/examples/models/models_basic_voxel.c @@ -103,7 +103,7 @@ int main(void) if (collision.hit && (collision.distance < closestDistance)) { closestDistance = collision.distance; - closestVoxelPosition = (Vector3){ x, y, z }; + closestVoxelPosition = (Vector3){ (float)x, (float)y, (float)z }; voxelFound = true; } } diff --git a/examples/models/models_bone_socket.c b/examples/models/models_bone_socket.c index ff44671c2..a89cca6e4 100644 --- a/examples/models/models_bone_socket.c +++ b/examples/models/models_bone_socket.c @@ -64,7 +64,7 @@ int main(void) int boneSocketIndex[BONE_SOCKETS] = { -1, -1, -1 }; // Search bones for sockets - for (int i = 0; i < characterModel.skeleton.boneCount; i++) + for (unsigned int i = 0; i < characterModel.skeleton.boneCount; i++) { if (TextIsEqual(characterModel.skeleton.bones[i].name, "socket_hat")) { diff --git a/examples/models/models_loading_m3d.c b/examples/models/models_loading_m3d.c index 06911bf53..3227d3c68 100644 --- a/examples/models/models_loading_m3d.c +++ b/examples/models/models_loading_m3d.c @@ -119,7 +119,7 @@ static void DrawModelSkeleton(ModelSkeleton skeleton, ModelAnimPose pose, float { // Loop to (boneCount - 1) because the last one is a special "no bone" bone, // needed to workaround buggy models without a -1, a cube is always drawn at the origin - for (int i = 0; i < skeleton.boneCount - 1; i++) + for (unsigned int i = 0; i < skeleton.boneCount - 1; i++) { // Display the frame-pose skeleton DrawCube(pose[i].translation, scale*0.05f, scale*0.05f, scale*0.05f, color); diff --git a/examples/textures/textures_clipboard_image.c b/examples/textures/textures_clipboard_image.c index 16501be31..b6c8ad9ac 100644 --- a/examples/textures/textures_clipboard_image.c +++ b/examples/textures/textures_clipboard_image.c @@ -82,8 +82,8 @@ int main(void) if (IsTextureValid(collection[i].texture)) { DrawTexturePro(collection[i].texture, - (Rectangle){0,0,collection[i].texture.width, collection[i].texture.height}, - (Rectangle){collection[i].position.x,collection[i].position.y,collection[i].texture.width, collection[i].texture.height}, + (Rectangle){0,0,(float)collection[i].texture.width, (float)collection[i].texture.height}, + (Rectangle){collection[i].position.x,collection[i].position.y, (float)collection[i].texture.width, (float)collection[i].texture.height}, (Vector2){collection[i].texture.width*0.5f, collection[i].texture.height*0.5f}, 0.0f, WHITE); } diff --git a/examples/textures/textures_framebuffer_rendering.c b/examples/textures/textures_framebuffer_rendering.c index 84ecce0ac..a22c99df1 100644 --- a/examples/textures/textures_framebuffer_rendering.c +++ b/examples/textures/textures_framebuffer_rendering.c @@ -115,7 +115,7 @@ int main(void) EndMode3D(); - DrawRectangleLines((int)((subjectTarget.texture.width - captureSize)/2.0f), (int)((subjectTarget.texture.height - captureSize)/2.0f), captureSize, captureSize, GREEN); + DrawRectangleLines((int)((subjectTarget.texture.width - captureSize)/2.0f), (int)((subjectTarget.texture.height - captureSize)/2.0f), (int)captureSize, (int)captureSize, GREEN); DrawText("Subject View", 10, subjectTarget.texture.height - 30, 20, BLACK); EndTextureMode(); diff --git a/projects/VS2022/examples/shapes_clock_of_clocks.vcxproj b/projects/VS2022/examples/shapes_clock_of_clocks.vcxproj index 94b1713ec..8639e5f95 100644 --- a/projects/VS2022/examples/shapes_clock_of_clocks.vcxproj +++ b/projects/VS2022/examples/shapes_clock_of_clocks.vcxproj @@ -292,7 +292,7 @@ Level3 Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) CompileAsC $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) @@ -309,7 +309,7 @@ Level3 Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) CompileAsC $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) @@ -345,7 +345,7 @@ Level3 Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) CompileAsC $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) @@ -366,7 +366,7 @@ Level3 Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) CompileAsC $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) @@ -410,7 +410,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) CompileAsC true @@ -432,7 +432,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) CompileAsC true @@ -476,7 +476,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) CompileAsC true @@ -504,7 +504,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) CompileAsC true diff --git a/projects/VS2022/examples/textures_cellular_automata.vcxproj b/projects/VS2022/examples/textures_cellular_automata.vcxproj index f8b434a6d..a46b127a6 100644 --- a/projects/VS2022/examples/textures_cellular_automata.vcxproj +++ b/projects/VS2022/examples/textures_cellular_automata.vcxproj @@ -292,7 +292,7 @@ Level3 Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) CompileAsC $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) @@ -309,7 +309,7 @@ Level3 Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) CompileAsC $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) @@ -345,7 +345,7 @@ Level3 Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) CompileAsC $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) @@ -366,7 +366,7 @@ Level3 Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) CompileAsC $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) @@ -410,7 +410,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) CompileAsC true @@ -432,7 +432,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) CompileAsC true @@ -476,7 +476,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) CompileAsC true @@ -504,7 +504,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) CompileAsC true