Enable -Wdeclaration-after-statement for compat with MSVC

This commit is contained in:
heinrich5991 2017-03-07 13:02:37 +01:00
parent 97bd89d1dc
commit c201d7959c
2 changed files with 25 additions and 20 deletions

View file

@ -395,6 +395,7 @@ foreach(target ${TARGETS_OWN})
target_compile_options(${target} PRIVATE /wd4800) # Implicit conversion of int to bool.
elseif(CMAKE_CXX_COMPILER_ID MATCHES Clang OR CMAKE_CXX_COMPILER_ID MATCHES GNU)
target_compile_options(${target} PRIVATE -Wall)
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:C>:-Wdeclaration-after-statement>)
#target_compile_options(${target} PRIVATE -Wextra)
#target_compile_options(${target} PRIVATE -Wformat=2) # Warn about format strings.
endif()

View file

@ -675,35 +675,38 @@ int64 time_get()
if(new_tick != -1)
new_tick = 0;
{
#if defined(CONF_PLATFORM_MACOSX)
static int got_timebase = 0;
mach_timebase_info_data_t timebase;
if(!got_timebase)
{
mach_timebase_info(&timebase);
}
uint64_t time = mach_absolute_time();
uint64_t q = time / timebase.denom;
uint64_t r = time % timebase.denom;
last = q * timebase.numer + r * timebase.numer / timebase.denom;
return last;
static int got_timebase = 0;
mach_timebase_info_data_t timebase;
uint64_t time;
uint64_t q;
uint64_t r;
if(!got_timebase)
{
mach_timebase_info(&timebase);
}
time = mach_absolute_time();
q = time / timebase.denom;
r = time % timebase.denom;
last = q * timebase.numer + r * timebase.numer / timebase.denom;
return last;
#elif defined(CONF_FAMILY_UNIX)
struct timespec spec;
clock_gettime(CLOCK_MONOTONIC, &spec);
last = (int64)spec.tv_sec*(int64)1000000+(int64)spec.tv_nsec/1000;
return last;
struct timespec spec;
clock_gettime(CLOCK_MONOTONIC, &spec);
last = (int64)spec.tv_sec*(int64)1000000+(int64)spec.tv_nsec/1000;
return last;
#elif defined(CONF_FAMILY_WINDOWS)
{
int64 t;
QueryPerformanceCounter((PLARGE_INTEGER)&t);
if(t<last) /* for some reason, QPC can return values in the past */
return last;
last = t;
return t;
}
#else
#error not implemented
#error not implemented
#endif
}
}
int64 time_freq()
@ -2513,10 +2516,11 @@ void shell_execute(const char *file)
#if defined(CONF_FAMILY_WINDOWS)
ShellExecute(NULL, NULL, file, NULL, NULL, SW_SHOWDEFAULT);
#elif defined(CONF_FAMILY_UNIX)
char* argv[2];
char *argv[2];
pid_t pid;
argv[0] = (char*) file;
argv[1] = NULL;
pid_t pid = fork();
pid = fork();
if(!pid)
execv(file, argv);
#endif