warning supression

This commit is contained in:
timerix 2023-01-17 22:25:28 +06:00
parent 912bea9397
commit c1218014db
4 changed files with 46 additions and 4 deletions

View File

@ -7,7 +7,7 @@ CMP_C=gcc
CMP_CPP=g++ CMP_CPP=g++
STD_C=c11 STD_C=c11
STD_CPP=c++17 STD_CPP=c++17
WARN_C="-Wall -Wno-discarded-qualifiers -Wno-int-conversion" WARN_C="-Wall -Wno-discarded-qualifiers"
WARN_CPP="-Wall" WARN_CPP="-Wall"
SRC_C="$( find src -name '*.c')" SRC_C="$( find src -name '*.c')"
SRC_CPP="$( find src -name '*.cpp')" SRC_CPP="$( find src -name '*.cpp')"

View File

@ -77,6 +77,8 @@ typedef uint8 bool;
a16,a17,a18,a19,a20,a21,a22,a23,\ a16,a17,a18,a19,a20,a21,a22,a23,\
a24,a25,a26,a27,a28,a29,a30,a31,\ a24,a25,a26,a27,a28,a29,a30,a31,\
a32,...) a32 a32,...) a32
// Macro for counting variadic arguments
// (see usage in kprint.h)
#define count_args(ARGS...) __count_args(\ #define count_args(ARGS...) __count_args(\
ARGS,\ ARGS,\
32,31,30,29,28,27,26,25,\ 32,31,30,29,28,27,26,25,\
@ -84,6 +86,30 @@ typedef uint8 bool;
16,15,14,13,12,11,10,9,\ 16,15,14,13,12,11,10,9,\
8, 7, 6, 5, 4, 3, 2, 1, 0) 8, 7, 6, 5, 4, 3, 2, 1, 0)
/*
Cross-platform warning supression.
WARNING_DISABLE( W_EXAMPLE,
some code producing W_EXAMPLE;
);
You can even embed it into macro in header (see kprint.h)
*/
#ifdef _MSC_VER
#define PRAGMA_WARNING_PUSH __pragma(warning( push ))
#define DISABLE_WARNING(wNumber) __pragma(warning( disable : wNumber ))
#define PRAGMA_WARNING_POP __pragma(warning( pop ))
#else
#define _PRAGMA(P) _Pragma(#P)
#define PRAGMA_WARNING_PUSH _PRAGMA(GCC diagnostic push)
#define PRAGMA_WARNING_DISABLE(wName) _PRAGMA(GCC diagnostic ignored wName)
#define PRAGMA_WARNING_POP _PRAGMA(GCC diagnostic pop)
#define W_INT_CONVERSION "-Wint-conversion"
#endif
#define WARNING_DISABLE(WARNING, CODE)\
PRAGMA_WARNING_PUSH\
PRAGMA_WARNING_DISABLE(WARNING)\
CODE;\
PRAGMA_WARNING_POP
#if __cplusplus #if __cplusplus
} }
#endif #endif

View File

@ -57,13 +57,24 @@ typedef union {
Maybe __ksprint(uint8 n, kprint_format* formats, __kprint_value_union* objects); Maybe __ksprint(uint8 n, kprint_format* formats, __kprint_value_union* objects);
#define ksprint(ARGS...) __ksprint(count_args(ARGS), __kprint_argsToArrs(count_args(ARGS),ARGS, __32zeroes)) #define ksprint(ARGS...) WARNING_DISABLE( W_INT_CONVERSION,\
__ksprint(count_args(ARGS), __kprint_argsToArrs(count_args(ARGS),ARGS, __32zeroes))\
)
Maybe __kfprint(FILE* fd, uint8 n, kprint_format* formats, __kprint_value_union* objects); Maybe __kfprint(FILE* fd, uint8 n, kprint_format* formats, __kprint_value_union* objects);
#define kfprint(FD, ARGS...) __kfprint(FD, count_args(ARGS), __kprint_argsToArrs(count_args(ARGS),ARGS, __32zeroes)) #define kfprint(FD, ARGS...) WARNING_DISABLE( W_INT_CONVERSION,\
__kfprint(FD, count_args(ARGS), __kprint_argsToArrs(count_args(ARGS),ARGS, __32zeroes))\
)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wint-conversion"
void __kprint(uint8 n, kprint_format* formats, __kprint_value_union* objects); void __kprint(uint8 n, kprint_format* formats, __kprint_value_union* objects);
#define kprint(ARGS...) __kprint(count_args(ARGS), __kprint_argsToArrs(count_args(ARGS),ARGS, __32zeroes)) #define kprint(ARGS...) WARNING_DISABLE( W_INT_CONVERSION,\
__kprint(count_args(ARGS), __kprint_argsToArrs(count_args(ARGS),ARGS, __32zeroes))\
)
#pragma GCC diagnostic pop
// can take (bgColor | fgColor) // can take (bgColor | fgColor)
void kprint_setColor(kprint_format f); void kprint_setColor(kprint_format f);

View File

@ -19,6 +19,11 @@ int main(){
ktDescriptors_beginInit(); ktDescriptors_beginInit();
ktDescriptors_initKerepTypes(); ktDescriptors_initKerepTypes();
ktDescriptors_endInit(); ktDescriptors_endInit();
for(ktid id=0; id<ktid_last; id++){
ktDescriptor d=ktDescriptor_get(id);
kprintf("{ id:%u name:%s size:%u freeMembers:%p toString:%p }\n",
d.id, d.name, d.size, d.freeMembers, d.toString);
}
kprintf("\e[97mkerep tests are starting!\n"); kprintf("\e[97mkerep tests are starting!\n");
optime("test_all",1,test_all()); optime("test_all",1,test_all());
ktDescriptors_free(); ktDescriptors_free();