Skip to content
This repository was archived by the owner on Apr 23, 2026. It is now read-only.

Commit 45d9f4f

Browse files
cleanup
1 parent 52a709b commit 45d9f4f

4 files changed

Lines changed: 9 additions & 8 deletions

File tree

cmake_files/warnings.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ function(clangwarn target)
6363
target_compile_options(${target} PRIVATE -Wno-gnu-anonymous-struct)
6464
target_compile_options(${target} PRIVATE -Wno-source-uses-openmp)
6565
target_compile_options(${target} PRIVATE -Wno-disabled-macro-expansion)
66+
target_compile_options(${target} PRIVATE -Wno-c++20-designator)
6667

6768
endfunction()
6869

include/cxxitimer.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ITimer {
4141

4242
protected:
4343
//* internal use only!
44-
explicit ITimer(int type, const timeval &interval = {1, 0}) noexcept;
44+
explicit ITimer(int type, const timeval &interval = {.tv_sec = 1, .tv_usec = 0}) noexcept;
4545

4646
//* internal use only!
4747
ITimer(int type, const timeval &interval, const timeval &value) noexcept;
@@ -192,7 +192,7 @@ class ITimer_Real : public ITimer {
192192
* @param interval timer interval
193193
* @exception std::logic_error instance exists
194194
*/
195-
explicit ITimer_Real(const timeval &interval = {1, 0});
195+
explicit ITimer_Real(const timeval &interval = {.tv_sec = 1, .tv_usec = 0});
196196

197197
/**
198198
* @brief create ITimer_Real instance
@@ -251,7 +251,7 @@ class ITimer_Virtual : public ITimer {
251251
* @param interval timer interval
252252
* @exception std::logic_error instance exists
253253
*/
254-
explicit ITimer_Virtual(const timeval &interval = {1, 0});
254+
explicit ITimer_Virtual(const timeval &interval = {.tv_sec = 1, .tv_usec = 0});
255255

256256
/**
257257
* @brief create ITimer_Virtual instance
@@ -313,7 +313,7 @@ class ITimer_Prof : public ITimer {
313313
* @param interval timer interval
314314
* @exception std::logic_error instance exists
315315
*/
316-
explicit ITimer_Prof(const timeval &interval = {1, 0});
316+
explicit ITimer_Prof(const timeval &interval = {.tv_sec = 1, .tv_usec = 0});
317317

318318
/**
319319
* @brief create ITimer_Prof instance

src/cxxitimer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace cxxitimer {
1414

1515
//* timeval to stop timer
16-
static constexpr itimerval STOP_TIMER = {{0, 0}, {0, 0}};
16+
static constexpr itimerval STOP_TIMER = {};
1717

1818
//* number of usec per second
1919
constexpr auto USEC_PER_SEC = static_cast<double>(1000000);
@@ -97,7 +97,7 @@ void ITimer::start() {
9797
if (running) throw std::logic_error("timer already started");
9898

9999
// create scaled timer value
100-
itimerval timer_val {timer_interval / speed_factor, timer_value / speed_factor};
100+
const itimerval timer_val = {.it_interval = timer_interval / speed_factor, .it_value = timer_value / speed_factor};
101101

102102
if (timer_val.it_interval.tv_sec < 0 || timer_val.it_interval.tv_usec < 0)
103103
throw std::runtime_error("timer interval is negative");
@@ -344,7 +344,7 @@ timeval double_to_timeval(const double time) noexcept {
344344
sec -= 1;
345345
usec += static_cast<suseconds_t>(USEC_PER_SEC);
346346
}
347-
return timeval {sec, usec};
347+
return timeval {.tv_sec = sec, .tv_usec = usec};
348348
}
349349

350350
} // namespace cxxitimer

test/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "cxxitimer.hpp"
77

88
#include <iostream>
9-
#include <signal.h>
9+
#include <csignal>
1010
#include <thread>
1111

1212
static int x = 0;

0 commit comments

Comments
 (0)