Skip to content

Commit

Permalink
fix(ILog): fixed unix compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
itas109 committed Apr 9, 2024
1 parent 11aa973 commit f001791
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
26 changes: 13 additions & 13 deletions include/CSerialPort/SerialPort_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,22 @@
#endif
#endif

//#ifdef CSERIALPORT_DEBUG
//#include <stdio.h>
// #ifdef CSERIALPORT_DEBUG
// #include <stdio.h>
//// #include <string.h> // strrchr
//#ifdef _WIN32
//#ifndef __func__
//#define __func__ __FUNCTION__
//#endif
// #ifdef _WIN32
// #ifndef __func__
// #define __func__ __FUNCTION__
// #endif
//// #define LOG_INFO(format, ...) printf("[CSERIALPORT_DEBUG] %s - " format " (%s:%d)\n", __func__, ##__VA_ARGS__, (strrchr("\\" __FILE__, '\\') + 1), __LINE__)
//#define LOG_INFO(format, ...) printf("[CSERIALPORT_DEBUG] %s - " format "\n", __func__, ##__VA_ARGS__)
//#else
// #define LOG_INFO(format, ...) printf("[CSERIALPORT_DEBUG] %s - " format "\n", __func__, ##__VA_ARGS__)
// #else
//// #define LOG_INFO(format, ...) printf("[CSERIALPORT_DEBUG] %s - " format " (%s:%d)\n", __func__, ##__VA_ARGS__, (strrchr("/" __FILE__, '/') + 1), __LINE__)
//#define LOG_INFO(format, ...) printf("[CSERIALPORT_DEBUG] %s - " format "\n", __func__, ##__VA_ARGS__)
//#endif
//#else
//#define LOG_INFO(format, ...)
//#endif
// #define LOG_INFO(format, ...) printf("[CSERIALPORT_DEBUG] %s - " format "\n", __func__, ##__VA_ARGS__)
// #endif
// #else
// #define LOG_INFO(format, ...)
// #endif

namespace itas109
{
Expand Down
6 changes: 3 additions & 3 deletions include/CSerialPort/ilog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class ILog
itas109::IUtils::strFormat(logMessage, 2048, "%s [%s] %s - %s\n", currentTime, levelStr, function, formatMessage);
m_logFile << logMessage;
m_logFile.flush();
printf(logMessage);
printf("%s", logMessage);
}
}

Expand All @@ -103,7 +103,7 @@ class ILog
: m_minLevel(LOG_INFO)
{
char fileName[40];
itas109::IUtils::strncpy(fileName, prefix,40);
itas109::IUtils::strncpy(fileName, prefix, 40);
getCurrentDate(fileName + itas109::IUtils::strlen(prefix));
itas109::IUtils::strncat(fileName, ".log", 45);
m_logFile.open(fileName, std::ios::out | std::ios::app);
Expand All @@ -128,8 +128,8 @@ class ILog
void getCurrentDate(char *dateStr)
{
struct tm ltm;
#if defined(_WIN32)
time_t now = time(0);
#if defined(_WIN32)
localtime_s(&ltm, &now);
#else
ltm = *localtime(&now);
Expand Down
6 changes: 3 additions & 3 deletions include/CSerialPort/iutils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,12 @@ class IUtils
strncpy(compilerName, "vs2022", 10);
break;
}
#elif defined(__GNUC__)
strncpy(compilerName, "gcc", 10);
strFormat(compilerVersion, 10, "%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
#elif defined(__clang__)
strncpy(compilerName, "clang", 10);
strFormat(compilerVersion, 10, "%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
#elif defined(__GNUC__)
strncpy(compilerName, "gcc", 10);
strFormat(compilerVersion, 10, "%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
#else
strncpy(compilerName, "unknown", 10);
strFormat(compilerVersion, 10, "%d.%d.%d", 0, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/SerialPortInfoWinBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#pragma comment(lib, "setupapi.lib")
#endif

//#include <ntddser.h> //GUID_DEVINTERFACE_COMPORT
// #include <ntddser.h> //GUID_DEVINTERFACE_COMPORT
#ifndef GUID_DEVINTERFACE_COMPORT
DEFINE_GUID(GUID_DEVINTERFACE_COMPORT, 0x86E0D1E0L, 0x8089, 0x11D0, 0x9C, 0xE4, 0x08, 0x00, 0x3E, 0x30, 0x1F, 0x73);
#endif
Expand Down

0 comments on commit f001791

Please sign in to comment.