Skip to content

Commit 94d2d16

Browse files
authored
Get rid of FORI, FORJ, FORIJ and clear warnings (#195)
* Get rid of FORI Signed-off-by: Aleksandr Motsjonov <[email protected]> * remove FORJ, FORIJ and fix warnings Signed-off-by: Aleksandr Motsjonov <[email protected]> * More size_t related refactoring Signed-off-by: Aleksandr Motsjonov <[email protected]> * Make build strict Signed-off-by: Aleksandr Motsjonov <[email protected]> * fix semicolon Signed-off-by: Aleksandr Motsjonov <[email protected]> * more gcc11 strict stuff Signed-off-by: Aleksandr Motsjonov <[email protected]> * more function ; removal Signed-off-by: Aleksandr Motsjonov <[email protected]> * Windows based warnings fix Signed-off-by: Aleksandr Motsjonov <[email protected]> * format Signed-off-by: Aleksandr Motsjonov <[email protected]> * fix up max threshold getter Signed-off-by: Aleksandr Motsjonov <[email protected]> --------- Signed-off-by: Aleksandr Motsjonov <[email protected]>
1 parent 2cca6c5 commit 94d2d16

18 files changed

+456
-409
lines changed

CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ set(RAWTOACES_UTIL_LIB "rawtoaces_util")
1616

1717
set( CMAKE_MACOSX_RPATH 1 )
1818

19+
# Set strict compiler flags by default for all builds
1920
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
20-
# set(warnings "/W4 /WX /EHsc")
21-
add_compile_options ( /W0 )
21+
# MSVC strict flags
22+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /EHsc")
23+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4 /WX")
2224
add_compile_definitions( NOMINMAX )
25+
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
26+
# GCC/Clang strict flags
27+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -pedantic")
28+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -Wextra -pedantic")
2329
endif()
2430

2531
if (NOT CONFIGURED_ONCE)

src/rawtoaces_core/define.h

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# include <windows.h>
2525
//# define snprintf _snprintf
2626
# define _CRT_SECURE_NO_WARNINGS
27-
# define cmp_str stricmp
27+
# define cmp_str _stricmp
2828
#else
2929
# define cmp_str strcasecmp
3030
#endif
@@ -37,11 +37,6 @@
3737
# define FALSE 0
3838
#endif
3939

40-
#define FORI( val ) for ( int i = 0; i < val; i++ )
41-
#define FORJ( val ) for ( int j = 0; j < val; j++ )
42-
#define FORIJ( val1, val2 ) \
43-
for ( int i = 0; i < val1; i++ ) \
44-
for ( int j = 0; j < val2; j++ )
4540
#define countSize( a ) ( static_cast<int>( sizeof( a ) / sizeof( ( a )[0] ) ) )
4641

4742
namespace rta
@@ -263,16 +258,16 @@ inline std::vector<std::string> openDir( std::string path = "." )
263258
}
264259

265260
return paths;
266-
};
261+
}
267262

268263
// Function to covert upper-case to lower-case
269264
inline void lowerCase( char *tex )
270265
{
271266
std::string tmp( tex );
272267

273-
FORI( tmp.size() )
274-
tex[i] = tolower( tex[i] );
275-
};
268+
for ( size_t i = 0; i < tmp.size(); i++ )
269+
tex[i] = static_cast<char>( tolower( tex[i] ) );
270+
}
276271

277272
// Function to check if a value is numeric
278273
inline bool isNumeric( const char *val )
@@ -283,21 +278,21 @@ inline bool isNumeric( const char *val )
283278
return (
284279
input.find_first_not_of( base.substr( 0, base.size() ) ) ==
285280
std::string::npos );
286-
};
281+
}
287282

288283
// Function to check if a input is a alphabetic letter
289284
inline bool isCTLetterDigit( const char c )
290285
{
291286
return (
292287
( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) || ( c == '-' ) ||
293288
isdigit( c ) );
294-
};
289+
}
295290

296291
// Function to check if a string is a valid input
297292
// to represent color temperature(s) (e.g., D60, 3200K)
298293
inline bool isValidCT( std::string str )
299294
{
300-
int i = 0;
295+
size_t i = 0;
301296
size_t length = str.length();
302297

303298
if ( length == 0 )
@@ -344,7 +339,7 @@ inline bool isValidCT( std::string str )
344339
return false;
345340

346341
return true;
347-
};
342+
}
348343

349344
} // namespace core
350345
} // namespace rta

0 commit comments

Comments
 (0)