Skip to content
Permalink
Browse files

no warnings when compiling /W3

   compiling all test cases and compilers in test.sbm
   Compilers:
     32-bit:
       VS2015
       VS2013
       VS2008
       VC6 (1998)
       clang-cl 9.0.1
     64-bit
       VS2015
       clang-cl 9.0.1
  • Loading branch information...
Sean Barrett
Sean Barrett committed Mar 4, 2019
1 parent 96b4748 commit a0b521fcf2bfbc88cf188a5d0af1a1cf47fe4d99
679 stb.h

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -514,7 +514,7 @@ static int stb__clex_parse_string(stb_lexer *lexer, char *p, int type)
}
*out = 0;
lexer->string = lexer->string_storage;
lexer->string_len = out - lexer->string_storage;
lexer->string_len = (int) (out - lexer->string_storage);
return stb__clex_token(lexer, type, start, p);
}

@@ -824,7 +824,7 @@ int stb_c_lexer_get_token(stb_lexer *lexer)
#endif // STB_C_LEXER_IMPLEMENTATION

#ifdef STB_C_LEXER_SELF_TEST

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

@@ -884,11 +884,12 @@ void dummy(void)
{
double some_floats[] = {
1.0501, -10.4e12, 5E+10,
#if 0 // not support in C++ or C-pre-99, so don't try to compile it
#if 0 // not supported in C++ or C-pre-99, so don't try to compile it, but let our parser test it
0x1.0p+24, 0xff.FP-8, 0x1p-23,
#endif
4.
};
(void) sizeof(some_floats);

printf("test %d",1); // https://github.com/nothings/stb/issues/13
}
@@ -897,7 +898,7 @@ int main(int argc, char **argv)
{
FILE *f = fopen("stb_c_lexer.h","rb");
char *text = (char *) malloc(1 << 20);
int len = f ? fread(text, 1, 1<<20, f) : -1;
int len = f ? (int) fread(text, 1, 1<<20, f) : -1;
stb_lexer lex;
if (len < 0) {
fprintf(stderr, "Error opening file\n");
@@ -709,7 +709,7 @@ static void stbcc__remove_clump_connection(stbcc_grid *g, int x1, int y1, int x2

static void stbcc__add_connections_to_adjacent_cluster(stbcc_grid *g, int cx, int cy, int dx, int dy)
{
unsigned char connected[STBCC__MAX_EDGE_CLUMPS_PER_CLUSTER][STBCC__MAX_EDGE_CLUMPS_PER_CLUSTER/8] = { 0 };
unsigned char connected[STBCC__MAX_EDGE_CLUMPS_PER_CLUSTER][STBCC__MAX_EDGE_CLUMPS_PER_CLUSTER/8] = { { 0 } };
int x = cx * STBCC__CLUSTER_SIZE_X;
int y = cy * STBCC__CLUSTER_SIZE_Y;
int step_x, step_y=0, i, j, k, n;
@@ -751,6 +751,7 @@ static void stbcc__add_connections_to_adjacent_cluster(stbcc_grid *g, int cx, in
n = STBCC__CLUSTER_SIZE_X;
} else {
assert(0);
return;
}

for (k=0; k < n; ++k) {
@@ -772,7 +773,7 @@ static void stbcc__add_connections_to_adjacent_cluster(stbcc_grid *g, int cx, in

static void stbcc__remove_connections_to_adjacent_cluster(stbcc_grid *g, int cx, int cy, int dx, int dy)
{
unsigned char disconnected[STBCC__MAX_EDGE_CLUMPS_PER_CLUSTER][STBCC__MAX_EDGE_CLUMPS_PER_CLUSTER/8] = { 0 };
unsigned char disconnected[STBCC__MAX_EDGE_CLUMPS_PER_CLUSTER][STBCC__MAX_EDGE_CLUMPS_PER_CLUSTER/8] = { { 0 } };
int x = cx * STBCC__CLUSTER_SIZE_X;
int y = cy * STBCC__CLUSTER_SIZE_Y;
int step_x, step_y=0, i, j, k, n;
@@ -811,6 +812,7 @@ static void stbcc__remove_connections_to_adjacent_cluster(stbcc_grid *g, int cx,
n = STBCC__CLUSTER_SIZE_X;
} else {
assert(0);
return;
}

for (k=0; k < n; ++k) {
@@ -954,11 +956,12 @@ static void stbcc__build_clumps_for_cluster(stbcc_grid *g, int cx, int cy)
for (j=1; j < STBCC__CLUSTER_SIZE_Y-1; ++j) {
for (i=1; i < STBCC__CLUSTER_SIZE_X-1; ++i) {
stbcc__tinypoint p = cbi.parent[j][i];
if (p.x == i && p.y == j)
if (p.x == i && p.y == j) {
if (STBCC__MAP_OPEN(g,x+i,y+j))
cbi.label[j][i] = label++;
else
cbi.label[j][i] = STBCC__NULL_CLUMPID;
}
}
}

@@ -308,6 +308,10 @@ CREDITS
Per Vognsen -- idea for hash table API/implementation
*/

#ifdef STBDS_UNIT_TESTS
#define _CRT_SECURE_NO_WARNINGS
#endif

#ifndef INCLUDE_STB_DS_H
#define INCLUDE_STB_DS_H

@@ -593,6 +597,7 @@ template<class T> static T * stbds_shmode_func_wrapper(T *, size_t elemsize, int
#include <string.h>

#ifndef STBDS_ASSERT
#define STBDS_ASSERT_WAS_UNDEFINED
#define STBDS_ASSERT(x) ((void) 0)
#endif

@@ -1442,6 +1447,9 @@ void stbds_strreset(stbds_string_arena *a)

#ifdef STBDS_UNIT_TESTS
#include <stdio.h>
#ifdef STBDS_ASSERT_WAS_UNDEFINED
#undef STBDS_ASSERT
#endif
#ifndef STBDS_ASSERT
#define STBDS_ASSERT assert
#include <assert.h>
@@ -1452,7 +1460,11 @@ typedef struct { int key,b,c,d; } stbds_struct;
static char buffer[256];
char *strkey(int n)
{
#if defined(_WIN32) && defined(__STDC_WANT_SECURE_LIB__)
sprintf_s(buffer, sizeof(buffer), "test_%d", n);
#else
sprintf(buffer, "test_%d", n);
#endif
return buffer;
}

@@ -1595,9 +1607,10 @@ void stbds_unit_tests(void)

for (i=0; i < testsize; i += 1) {
stbds_struct s = { i,i*2,i*3,i*4 };
stbds_struct t = { i,i*2,i*3,i*4 };
stbds_struct t = { i,i*2,i*3+1,i*4 };
if (i & 1) STBDS_ASSERT(hmgets(map2, s.key).d == 0);
else STBDS_ASSERT(hmgets(map2, s.key).d == i*4);
STBDS_ASSERT(hmget(map, t) == 0);
}
hmfree(map2);
#endif
@@ -166,7 +166,7 @@ int main(int argc, char **argv)
typedef struct stbhw_tileset stbhw_tileset;

// returns description of last error produced by any function (not thread-safe)
STBHW_EXTERN char *stbhw_get_last_error(void);
STBHW_EXTERN const char *stbhw_get_last_error(void);

// build a tileset from an image that conforms to a template created by this
// library. (you allocate storage for stbhw_tileset and function fills it out;
@@ -345,10 +345,10 @@ static signed char c_color[STB_HBWANG_MAX_Y+6][STB_HBWANG_MAX_X+6];
static signed char v_color[STB_HBWANG_MAX_Y+6][STB_HBWANG_MAX_X+5];
static signed char h_color[STB_HBWANG_MAX_Y+5][STB_HBWANG_MAX_X+6];

static char *stbhw_error;
STBHW_EXTERN char *stbhw_get_last_error(void)
static const char *stbhw_error;
STBHW_EXTERN const char *stbhw_get_last_error(void)
{
char *temp = stbhw_error;
const char *temp = stbhw_error;
stbhw_error = 0;
return temp;
}
@@ -717,7 +717,7 @@ STBHW_EXTERN int stbhw_generate_image(stbhw_tileset *ts, int **weighting, unsign
// to avoid really obvious repetition (which happens easily with extreme weights)
for (j=0; j < ymax-3; ++j) {
for (i=0; i < xmax-3; ++i) {
int p = (i-j+1) & 3; // corner type
//int p = (i-j+1) & 3; // corner type // unused, not sure what the intent was so commenting it out
STB_HBWANG_ASSERT(i+3 < STB_HBWANG_MAX_X+6);
STB_HBWANG_ASSERT(j+3 < STB_HBWANG_MAX_Y+6);
if (stbhw__match(i,j) && stbhw__match(i,j+1) && stbhw__match(i,j+2)
@@ -747,7 +747,7 @@ STBHW_EXTERN int stbhw_generate_image(stbhw_tileset *ts, int **weighting, unsign
} else {
i = phase-4;
}
for (i;; i += 4) {
for (;; i += 4) {
int xpos = i * sidelen;
if (xpos >= w)
break;
@@ -798,7 +798,7 @@ STBHW_EXTERN int stbhw_generate_image(stbhw_tileset *ts, int **weighting, unsign
} else {
i = phase-4;
}
for (i;; i += 4) {
for (;; i += 4) {
int xpos = i * sidelen;
if (xpos >= w)
break;
@@ -339,11 +339,13 @@ typedef unsigned short stbi_us;
extern "C" {
#endif

#ifndef STBIDEF
#ifdef STB_IMAGE_STATIC
#define STBIDEF static
#else
#define STBIDEF extern
#endif
#endif

//////////////////////////////////////////////////////////////////////////////
//
@@ -1182,7 +1184,7 @@ STBI_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int
#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)
STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input)
{
return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, bufferlen, NULL, NULL);
return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL);
}
#endif

@@ -193,6 +193,7 @@ typedef uint16_t stbir_uint16;
typedef uint32_t stbir_uint32;
#endif

#ifndef STBIRDEF
#ifdef STB_IMAGE_RESIZE_STATIC
#define STBIRDEF static
#else
@@ -202,7 +203,7 @@ typedef uint32_t stbir_uint32;
#define STBIRDEF extern
#endif
#endif

#endif

//////////////////////////////////////////////////////////////////////////////
//
@@ -2324,8 +2325,9 @@ static int stbir__resize_allocated(stbir__info *info,
if (alpha_channel < 0)
flags |= STBIR_FLAG_ALPHA_USES_COLORSPACE | STBIR_FLAG_ALPHA_PREMULTIPLIED;

if (!(flags&STBIR_FLAG_ALPHA_USES_COLORSPACE) || !(flags&STBIR_FLAG_ALPHA_PREMULTIPLIED))
if (!(flags&STBIR_FLAG_ALPHA_USES_COLORSPACE) || !(flags&STBIR_FLAG_ALPHA_PREMULTIPLIED)) {
STBIR_ASSERT(alpha_channel >= 0 && alpha_channel < info->channels);
}

if (alpha_channel >= info->channels)
return 0;
@@ -299,7 +299,7 @@ STBIW_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned in

STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input)
{
return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, bufferlen, NULL, NULL);
return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL);
}
#endif

@@ -736,8 +736,8 @@ static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, f
char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n";
s->func(s->context, header, sizeof(header)-1);

#ifdef STBI_MSC_SECURE_CRT
len = sprintf_s(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x);
#ifdef __STDC_WANT_SECURE_LIB__
len = sprintf_s(buffer, sizeof(buffer), "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x);
#else
len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x);
#endif
Oops, something went wrong.

0 comments on commit a0b521f

Please sign in to comment.
You can’t perform that action at this time.