Ikomia-dev / IkomiaCore

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Move #include outside the Ikomia::Utils namespace to avoid compilation error

madruon opened this issue · comments

Inside the Utils/CTimer.hpp file, some #include are declared inside the Ikomia::Utils namespace. This may cause compilation issues.

To avoid this, extract all the #include directives outside the Ikomia::Utils namespace:

#ifndef CTIMER_HPP
#define CTIMER_HPP

#include <string>
#include <iostream>


#if defined(__MACH__)

    #include <mach/clock.h>
    #include <mach/mach.h>

#elif (defined(linux) || defined(__linux__) || defined(__linux)) || (defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__))

    #include <time.h>
    #include <sys/time.h>

#elif defined(_WIN32)

    #if defined(_MSC_VER) && !defined(NOMINMAX)
        #define NOMINMAX // Otherwise MS compilers act like idiots when using std::numeric_limits<>::max() and including windows.h
    #endif

    #include <windows.h>

#endif



// ~Nanosecond-precision cross-platform (linux/bsd/mac/windows, C++03/C++11) simple timer class:

namespace Ikomia
{
    namespace Utils
    {

// Mac OSX implementation:
#if defined(__MACH__)
    /**
     * @brief
     * This class implements a nanosecond-precision cross-platform(Linux, BSD, Mac OS X, Windows) timer class.
     */
    class CTimer
    {
        [...]
    };

// Linux/BSD implementation:
#elif (defined(linux) || defined(__linux__) || defined(__linux)) || (defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__))

    /**
     * @brief
     * This class implements a nanosecond-precision cross-platform(Linux, BSD, Mac OS X, Windows) timer class.
     */
    class CTimer
    {
        [...]
    };

// Windows implementation:
#elif defined(_WIN32)

    /**
     * @brief
     * This class implements a nanosecond-precision cross-platform(Linux, BSD, Mac OS X, Windows) timer class.
     */
    class CTimer
    {
        [...]
    };
#endif
// Else: failure warning - your OS is not supported

    } // namespace Utils
} // namespace Ikomia

#endif // CTIMER_HPP