Skip to content

Commit a18051f

Browse files
authored
Fix various warnings when building in VC2022 (#6020)
1 parent ac06acb commit a18051f

12 files changed

Lines changed: 47 additions & 47 deletions

examples/audio/audio_raw_stream.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ int main(void)
9090
for (int i = 0; i < BUFFER_SIZE; i++)
9191
{
9292
int wavelength = SAMPLE_RATE/sineFrequency;
93-
buffer[i] = sin(2*PI*sineIndex/wavelength);
93+
buffer[i] = sinf(2*PI*sineIndex/wavelength);
9494
sineIndex++;
9595

9696
if (sineIndex >= wavelength)
@@ -116,17 +116,17 @@ int main(void)
116116
DrawText("Up/down to change frequency", 10, 10, 20, DARKGRAY);
117117
DrawText("Left/right to pan", 10, 30, 20, DARKGRAY);
118118

119-
int windowStart = (GetTime() - sineStartTime)*SAMPLE_RATE;
120-
int windowSize = 0.1f*SAMPLE_RATE;
119+
int windowStart = (int)((GetTime() - sineStartTime)*SAMPLE_RATE);
120+
int windowSize = SAMPLE_RATE/10;
121121
int wavelength = SAMPLE_RATE/sineFrequency;
122122

123123
// Draw a sine wave with the same frequency as the one being sent to the audio stream
124124
for (int i = 0; i < screenWidth; i++)
125125
{
126126
int t0 = windowStart + i*windowSize/screenWidth;
127127
int t1 = windowStart + (i + 1)*windowSize/screenWidth;
128-
Vector2 startPos = { i, 250 + 50*sin(2*PI*t0/wavelength) };
129-
Vector2 endPos = { i + 1, 250 + 50*sin(2*PI*t1/wavelength) };
128+
Vector2 startPos = { (float)i, 250 + 50*sinf(2*PI*t0/wavelength) };
129+
Vector2 endPos = { (float)i + 1, 250 + 50*sinf(2*PI*t1/wavelength) };
130130
DrawLineV(startPos, endPos, RED);
131131
}
132132

examples/audio/audio_stream_callback.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ int main(void)
133133
// Draw the last 10 ms of uploaded audio
134134
for (int i = 0; i < screenWidth; i++)
135135
{
136-
Vector2 startPos = { i, 250 - 50*buffer[SAMPLE_RATE - SAMPLE_RATE/100 + i*SAMPLE_RATE/100/screenWidth] };
137-
Vector2 endPos = { i + 1, 250 - 50*buffer[SAMPLE_RATE - SAMPLE_RATE/100 + (i + 1)*SAMPLE_RATE/100/screenWidth] };
136+
Vector2 startPos = {(float)i, 250 - 50*buffer[SAMPLE_RATE - SAMPLE_RATE/100 + i*SAMPLE_RATE/100/screenWidth] };
137+
Vector2 endPos = { (float)(i + 1), 250 - 50*buffer[SAMPLE_RATE - SAMPLE_RATE/100 + (i + 1)*SAMPLE_RATE/100/screenWidth] };
138138
DrawLineV(startPos, endPos, RED);
139139
}
140140

@@ -161,9 +161,9 @@ static void SineCallback(void *framesOut, unsigned int frameCount)
161161
int wavelength = SAMPLE_RATE/waveFrequency;
162162

163163
// Synthesize the sine wave
164-
for (int i = 0; i < frameCount; i++)
164+
for (unsigned int i = 0; i < frameCount; i++)
165165
{
166-
((float *)framesOut)[i] = sin(2*PI*waveIndex/wavelength);
166+
((float *)framesOut)[i] = sinf(2*PI*waveIndex/wavelength);
167167

168168
waveIndex++;
169169

@@ -175,18 +175,18 @@ static void SineCallback(void *framesOut, unsigned int frameCount)
175175
}
176176

177177
// Save the synthesized samples for later drawing
178-
for (int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount];
179-
for (int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i];
178+
for (unsigned int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount];
179+
for (unsigned int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i];
180180
}
181181

182182
static void SquareCallback(void *framesOut, unsigned int frameCount)
183183
{
184184
int wavelength = SAMPLE_RATE/waveFrequency;
185185

186186
// Synthesize the square wave
187-
for (int i = 0; i < frameCount; i++)
187+
for (unsigned int i = 0; i < frameCount; i++)
188188
{
189-
((float *)framesOut)[i] = (waveIndex < wavelength/2)? 1 : -1;
189+
((float *)framesOut)[i] = (waveIndex < wavelength/2)? 1.0f : -1.0f;
190190
waveIndex++;
191191

192192
if (waveIndex >= wavelength)
@@ -197,16 +197,16 @@ static void SquareCallback(void *framesOut, unsigned int frameCount)
197197
}
198198

199199
// Save the synthesized samples for later drawing
200-
for (int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount];
201-
for (int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i];
200+
for (unsigned int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount];
201+
for (unsigned int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i];
202202
}
203203

204204
static void TriangleCallback(void *framesOut, unsigned int frameCount)
205205
{
206206
int wavelength = SAMPLE_RATE/waveFrequency;
207207

208208
// Synthesize the triangle wave
209-
for (int i = 0; i < frameCount; i++)
209+
for (unsigned int i = 0; i < frameCount; i++)
210210
{
211211
((float *)framesOut)[i] = (waveIndex < wavelength/2)? (-1 + 2.0f*waveIndex/(wavelength/2)) : (1 - 2.0f*(waveIndex - wavelength/2)/(wavelength/2));
212212
waveIndex++;
@@ -219,16 +219,16 @@ static void TriangleCallback(void *framesOut, unsigned int frameCount)
219219
}
220220

221221
// Save the synthesized samples for later drawing
222-
for (int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount];
223-
for (int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i];
222+
for (unsigned int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount];
223+
for (unsigned int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i];
224224
}
225225

226226
static void SawtoothCallback(void *framesOut, unsigned int frameCount)
227227
{
228228
int wavelength = SAMPLE_RATE/waveFrequency;
229229

230230
// Synthesize the sawtooth wave
231-
for (int i = 0; i < frameCount; i++)
231+
for (unsigned int i = 0; i < frameCount; i++)
232232
{
233233
((float *)framesOut)[i] = -1 + 2.0f*waveIndex/wavelength;
234234
waveIndex++;
@@ -241,6 +241,6 @@ static void SawtoothCallback(void *framesOut, unsigned int frameCount)
241241
}
242242

243243
// Save the synthesized samples for later drawing
244-
for (int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount];
245-
for (int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i];
244+
for (unsigned int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount];
245+
for (unsigned int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float*)framesOut)[i];
246246
}

examples/core/core_highdpi_testbed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ int main(void)
8888
DrawCircleV(GetMousePosition(), 20, MAROON);
8989
DrawRectangleRec((Rectangle) { mousePos.x - 25, mousePos.y, 50, 2 }, BLACK);
9090
DrawRectangleRec((Rectangle) { mousePos.x, mousePos.y - 25, 2, 50 }, BLACK);
91-
DrawText(TextFormat("[%i,%i]", GetMouseX(), GetMouseY()), mousePos.x - 44,
91+
DrawText(TextFormat("[%i,%i]", GetMouseX(), GetMouseY()), (int)mousePos.x - 44,
9292
(mousePos.y > GetScreenHeight() - 60)? (int)mousePos.y - 46 : (int)mousePos.y + 30, 20, BLACK);
9393

9494
EndDrawing();

examples/models/models_animation_blend_custom.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,12 @@ static void UpdateModelAnimationBones(Model *model, ModelAnimation *anim0, int f
212212
if (frame1 < 0) frame1 = 0;
213213

214214
// Get bone count (use minimum of all to be safe)
215-
int boneCount = model->skeleton.boneCount;
215+
unsigned int boneCount = model->skeleton.boneCount;
216216
if (anim0->boneCount < boneCount) boneCount = anim0->boneCount;
217217
if (anim1->boneCount < boneCount) boneCount = anim1->boneCount;
218218

219219
// Blend each bone
220-
for (int boneIndex = 0; boneIndex < boneCount; boneIndex++)
220+
for (unsigned int boneIndex = 0; boneIndex < boneCount; boneIndex++)
221221
{
222222
// Determine blend factor for this bone
223223
float boneBlendFactor = blend;

examples/models/models_animation_blending.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ int main(void)
252252

253253
GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
254254
GuiSetStyle(DEFAULT, TEXT_SIZE, GuiGetFont().baseSize*2);
255-
GuiLabel((Rectangle){ 0, GetScreenHeight() - 100.0f, GetScreenWidth(), 40 }, "PRESS SPACE to START BLENDING");
255+
GuiLabel((Rectangle){ 0, GetScreenHeight() - 100.0f, (float)GetScreenWidth(), 40 }, "PRESS SPACE to START BLENDING");
256256
GuiSetStyle(DEFAULT, TEXT_SIZE, GuiGetFont().baseSize);
257257
GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
258258

examples/models/models_basic_voxel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ int main(void)
103103
if (collision.hit && (collision.distance < closestDistance))
104104
{
105105
closestDistance = collision.distance;
106-
closestVoxelPosition = (Vector3){ x, y, z };
106+
closestVoxelPosition = (Vector3){ (float)x, (float)y, (float)z };
107107
voxelFound = true;
108108
}
109109
}

examples/models/models_bone_socket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ int main(void)
6464
int boneSocketIndex[BONE_SOCKETS] = { -1, -1, -1 };
6565

6666
// Search bones for sockets
67-
for (int i = 0; i < characterModel.skeleton.boneCount; i++)
67+
for (unsigned int i = 0; i < characterModel.skeleton.boneCount; i++)
6868
{
6969
if (TextIsEqual(characterModel.skeleton.bones[i].name, "socket_hat"))
7070
{

examples/models/models_loading_m3d.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static void DrawModelSkeleton(ModelSkeleton skeleton, ModelAnimPose pose, float
119119
{
120120
// Loop to (boneCount - 1) because the last one is a special "no bone" bone,
121121
// needed to workaround buggy models without a -1, a cube is always drawn at the origin
122-
for (int i = 0; i < skeleton.boneCount - 1; i++)
122+
for (unsigned int i = 0; i < skeleton.boneCount - 1; i++)
123123
{
124124
// Display the frame-pose skeleton
125125
DrawCube(pose[i].translation, scale*0.05f, scale*0.05f, scale*0.05f, color);

examples/textures/textures_clipboard_image.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ int main(void)
8282
if (IsTextureValid(collection[i].texture))
8383
{
8484
DrawTexturePro(collection[i].texture,
85-
(Rectangle){0,0,collection[i].texture.width, collection[i].texture.height},
86-
(Rectangle){collection[i].position.x,collection[i].position.y,collection[i].texture.width, collection[i].texture.height},
85+
(Rectangle){0,0,(float)collection[i].texture.width, (float)collection[i].texture.height},
86+
(Rectangle){collection[i].position.x,collection[i].position.y, (float)collection[i].texture.width, (float)collection[i].texture.height},
8787
(Vector2){collection[i].texture.width*0.5f, collection[i].texture.height*0.5f},
8888
0.0f, WHITE);
8989
}

examples/textures/textures_framebuffer_rendering.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ int main(void)
115115

116116
EndMode3D();
117117

118-
DrawRectangleLines((int)((subjectTarget.texture.width - captureSize)/2.0f), (int)((subjectTarget.texture.height - captureSize)/2.0f), captureSize, captureSize, GREEN);
118+
DrawRectangleLines((int)((subjectTarget.texture.width - captureSize)/2.0f), (int)((subjectTarget.texture.height - captureSize)/2.0f), (int)captureSize, (int)captureSize, GREEN);
119119
DrawText("Subject View", 10, subjectTarget.texture.height - 30, 20, BLACK);
120120

121121
EndTextureMode();

0 commit comments

Comments
 (0)