diff --git a/src/include/switch_platform.h b/src/include/switch_platform.h index a23d7e5f3a..2b86e4c196 100644 --- a/src/include/switch_platform.h +++ b/src/include/switch_platform.h @@ -39,10 +39,15 @@ extern "C" { #endif #ifdef _MSC_VER -// C4200 Non standard extension C zero sized array -// C4204: nonstandard extension used : non-constant aggregate initializer +/* disable the following warnings + * C4152: non standard extension, function/data ptr conversion in expression + * C4054: A function pointer is cast (possibly incorrectly) to a data pointer. + * C4100: The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored. + * C4142: A type is redefined in a manner that has no effect on the generated code. + * C4200: Non standard extension C zero sized array + * C4204: nonstandard extension used : non-constant aggregate initializer + */ #pragma warning(disable:4152 4054 4100 4142 4200 4204) -#endif #if (_MSC_VER >= 1400) // VC8+ #ifndef _CRT_SECURE_NO_DEPRECATE @@ -53,6 +58,36 @@ extern "C" { #endif #endif // VC8+ +#if _MSC_VER < 1300 +#ifndef __FUNCTION__ +#define __FUNCTION__ "" +#endif +#endif + +#ifndef uint32_t +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +typedef __int8 int8_t; +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned long in_addr_t; +#endif + +#else +#include +#ifndef getpid +#include +#include +#include +#include +#endif + +#endif // _MSC_VER + + #ifdef WIN32 #if defined(SWITCH_CORE_DECLARE_STATIC) #define SWITCH_DECLARE(type) type __stdcall @@ -80,34 +115,6 @@ extern "C" { #define SWITCH_DECLARE_NONSTD(type) type #define SWITCH_MOD_DECLARE(type) type #define SWITCH_DECLARE_DATA -#ifndef getpid -#include -#include -#include -#include -#endif -#endif - -#ifndef uint32_t -#ifdef WIN32 -typedef unsigned __int8 uint8_t; -typedef unsigned __int16 uint16_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int64 uint64_t; -typedef __int8 int8_t; -typedef __int16 int16_t; -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned long in_addr_t; -#else -#include -#endif -#endif - -#if defined(_MSC_VER) && _MSC_VER < 1300 -#ifndef __FUNCTION__ -#define __FUNCTION__ "" -#endif #endif #ifdef DOXYGEN diff --git a/src/switch_core.c b/src/switch_core.c index 02dcc0073a..b05f215949 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -115,11 +115,14 @@ static void switch_core_standard_on_transmit(switch_core_session *session); static struct switch_core_runtime runtime; +#pragma warning( push ) +#pragma warning( disable : 4100 ) static int handle_SIGPIPE(int sig) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Sig Pipe!\n"); return 0; } +#pragma warning( pop ) #ifdef TRAP_BUS static int handle_SIGBUS(int sig) @@ -130,11 +133,14 @@ static int handle_SIGBUS(int sig) #endif /* no ctl-c mofo */ + +#pragma warning( push ) +#pragma warning( disable : 4100 ) static int handle_SIGINT(int sig) { return 0; } - +#pragma warning( pop ) static void db_pick_path(char *dbname, char *buf, size_t size) { @@ -617,6 +623,8 @@ SWITCH_DECLARE(switch_status) switch_core_timer_destroy(switch_timer *timer) return SWITCH_STATUS_SUCCESS; } +#pragma warning( push ) +#pragma warning( disable : 4100 ) static void *switch_core_service_thread(switch_thread *thread, void *obj) { switch_core_thread_session *data = obj; @@ -648,6 +656,7 @@ static void *switch_core_service_thread(switch_thread *thread, void *obj) data->running = 0; return NULL; } +#pragma warning( pop ) /* Either add a timeout here or make damn sure the thread cannot get hung somehow (my preference) */ SWITCH_DECLARE(void) switch_core_thread_session_end(switch_core_thread_session *thread_session) @@ -1658,11 +1667,13 @@ static void switch_core_standard_on_loopback(switch_core_session *session) } } +#pragma warning( push ) +#pragma warning( disable : 4100 ) static void switch_core_standard_on_transmit(switch_core_session *session) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Standard TRANSMIT\n"); } - +#pragma warning( pop ) SWITCH_DECLARE(void) switch_core_session_signal_state_change(switch_core_session *session) { @@ -1978,10 +1989,13 @@ SWITCH_DECLARE(switch_status) switch_core_hash_init(switch_hash **hash, switch_m return SWITCH_STATUS_GENERR; } +#pragma warning( push ) +#pragma warning( disable : 4100 ) SWITCH_DECLARE(switch_status) switch_core_hash_destroy(switch_hash *hash) { return SWITCH_STATUS_SUCCESS; } +#pragma warning( pop ) SWITCH_DECLARE(switch_status) switch_core_hash_insert_dup(switch_hash *hash, char *key, void *data) { diff --git a/src/switch_event.c b/src/switch_event.c index 817088e309..31eabd8033 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -143,6 +143,8 @@ static int switch_events_match(switch_event *event, switch_event_node *node) return match; } +#pragma warning( push ) +#pragma warning( disable : 4100 ) static void *SWITCH_THREAD_FUNC switch_event_thread(switch_thread *thread, void *obj) { switch_event_node *node; @@ -195,6 +197,7 @@ static void *SWITCH_THREAD_FUNC switch_event_thread(switch_thread *thread, void THREAD_RUNNING = 0; return NULL; } +#pragma warning( pop ) SWITCH_DECLARE(switch_status) switch_event_running(void) { diff --git a/src/switch_loadable_module.c b/src/switch_loadable_module.c index 0c01e7f7ec..f61f98a7f0 100644 --- a/src/switch_loadable_module.c +++ b/src/switch_loadable_module.c @@ -70,6 +70,8 @@ struct switch_loadable_module_container { static struct switch_loadable_module_container loadable_modules; +#pragma warning( push ) +#pragma warning( disable : 4100 ) static void *switch_loadable_module_exec(switch_thread *thread, void *obj) { switch_status status = SWITCH_STATUS_SUCCESS; @@ -92,6 +94,7 @@ static void *switch_loadable_module_exec(switch_thread *thread, void *obj) switch_yield(1000000); return NULL; } +#pragma warning( pop ) static switch_status switch_loadable_module_load_file(char *filename, switch_memory_pool *pool, switch_loadable_module **new_module) @@ -505,6 +508,8 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool *pool, } +#pragma warning( push ) +#pragma warning( disable : 4100 ) SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(switch_memory_pool *pool, switch_codec_interface **array, int arraylen, char **prefs, int preflen) { @@ -522,6 +527,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(switch_memory_pool return i; } +#pragma warning( pop ) SWITCH_DECLARE(switch_status) switch_api_execute(char *cmd, char *arg, char *retbuf, size_t len) {