diff --git a/DocOutput.cpp b/DocOutput.cpp index d9f6f29..fa532b7 100644 --- a/DocOutput.cpp +++ b/DocOutput.cpp @@ -142,7 +142,7 @@ #ifdef _WIN32 -#include // for OutputDebugStringA +#include // for OutputDebugStringA static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void * /*user_data*/, int line, const char* file) { // DocOutputDevice* context = (DocOutputDevice*)user_data; diff --git a/DocOutput.cpp b/DocOutput.cpp index d9f6f29..fa532b7 100644 --- a/DocOutput.cpp +++ b/DocOutput.cpp @@ -142,7 +142,7 @@ #ifdef _WIN32 -#include // for OutputDebugStringA +#include // for OutputDebugStringA static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void * /*user_data*/, int line, const char* file) { // DocOutputDevice* context = (DocOutputDevice*)user_data; diff --git a/DocTemplate.cpp b/DocTemplate.cpp index 37787cb..1b8a750 100644 --- a/DocTemplate.cpp +++ b/DocTemplate.cpp @@ -18,7 +18,7 @@ #ifndef _WIN32 # define HAVE_CONSTEXPR #else -# include +# include #endif #ifdef HAVE_CONSTEXPR diff --git a/DocOutput.cpp b/DocOutput.cpp index d9f6f29..fa532b7 100644 --- a/DocOutput.cpp +++ b/DocOutput.cpp @@ -142,7 +142,7 @@ #ifdef _WIN32 -#include // for OutputDebugStringA +#include // for OutputDebugStringA static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void * /*user_data*/, int line, const char* file) { // DocOutputDevice* context = (DocOutputDevice*)user_data; diff --git a/DocTemplate.cpp b/DocTemplate.cpp index 37787cb..1b8a750 100644 --- a/DocTemplate.cpp +++ b/DocTemplate.cpp @@ -18,7 +18,7 @@ #ifndef _WIN32 # define HAVE_CONSTEXPR #else -# include +# include #endif #ifdef HAVE_CONSTEXPR diff --git a/Framework/GenericTableUI.h b/Framework/GenericTableUI.h index d7ca6d2..34bcb07 100644 --- a/Framework/GenericTableUI.h +++ b/Framework/GenericTableUI.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "GenericTable.h" @@ -75,7 +76,11 @@ { //for (int i = 0; i < m_genericTable->m_columnNames.size() - 1; i++) // m_view->horizontalHeader()->setSectionResizeMode(i, QHeaderView::ResizeToContents); +#if QT_VERSION >= 0x050000 m_view->horizontalHeader()->setSectionResizeMode((int)m_genericTable->m_columnNames.size() - 1, QHeaderView::Stretch); +#else + m_view->horizontalHeader()->setResizeMode((int)m_genericTable->m_columnNames.size() - 1, QHeaderView::Stretch); +#endif } } @@ -146,8 +151,10 @@ void reload() { +#if QT_VERSION >= 0x050000 beginResetModel(); endResetModel(); +#endif beginInsertRows(QModelIndex(), 0, (int)m_genericTable->size()); endInsertRows(); m_view->scrollToBottom(); diff --git a/DocOutput.cpp b/DocOutput.cpp index d9f6f29..fa532b7 100644 --- a/DocOutput.cpp +++ b/DocOutput.cpp @@ -142,7 +142,7 @@ #ifdef _WIN32 -#include // for OutputDebugStringA +#include // for OutputDebugStringA static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void * /*user_data*/, int line, const char* file) { // DocOutputDevice* context = (DocOutputDevice*)user_data; diff --git a/DocTemplate.cpp b/DocTemplate.cpp index 37787cb..1b8a750 100644 --- a/DocTemplate.cpp +++ b/DocTemplate.cpp @@ -18,7 +18,7 @@ #ifndef _WIN32 # define HAVE_CONSTEXPR #else -# include +# include #endif #ifdef HAVE_CONSTEXPR diff --git a/Framework/GenericTableUI.h b/Framework/GenericTableUI.h index d7ca6d2..34bcb07 100644 --- a/Framework/GenericTableUI.h +++ b/Framework/GenericTableUI.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "GenericTable.h" @@ -75,7 +76,11 @@ { //for (int i = 0; i < m_genericTable->m_columnNames.size() - 1; i++) // m_view->horizontalHeader()->setSectionResizeMode(i, QHeaderView::ResizeToContents); +#if QT_VERSION >= 0x050000 m_view->horizontalHeader()->setSectionResizeMode((int)m_genericTable->m_columnNames.size() - 1, QHeaderView::Stretch); +#else + m_view->horizontalHeader()->setResizeMode((int)m_genericTable->m_columnNames.size() - 1, QHeaderView::Stretch); +#endif } } @@ -146,8 +151,10 @@ void reload() { +#if QT_VERSION >= 0x050000 beginResetModel(); endResetModel(); +#endif beginInsertRows(QModelIndex(), 0, (int)m_genericTable->size()); endInsertRows(); m_view->scrollToBottom(); diff --git a/Framework/Utilities.cpp b/Framework/Utilities.cpp index 22a00dc..65b023b 100644 --- a/Framework/Utilities.cpp +++ b/Framework/Utilities.cpp @@ -87,8 +87,8 @@ va_list args; va_start(args, a_format); #ifdef _WIN32 - auto sizeRequired = size_t(_vscprintf(a_format, args) + 1); - auto message = (char*)_alloca(sizeRequired); + size_t sizeRequired = size_t(_vscprintf(a_format, args) + 1); + char* message = (char*)_alloca(sizeRequired); _vsnprintf(message, sizeRequired, a_format, args); if (g_currentModule.m_messageLogger) g_currentModule.m_messageLogger->logMessage(a_logLevel, a_location, message); @@ -109,8 +109,8 @@ va_list args; va_start(args, a_format); #ifdef _WIN32 - auto sizeRequired = size_t(_vscprintf(a_format, args) + 1); - auto message = (char*)_alloca(sizeRequired); + size_t sizeRequired = size_t(_vscprintf(a_format, args) + 1); + char* message = (char*)_alloca(sizeRequired); _vsnprintf(message, sizeRequired, a_format, args); if (g_currentModule.m_errorHandler) g_currentModule.m_errorHandler->handleError(a_result, a_location, message); diff --git a/DocOutput.cpp b/DocOutput.cpp index d9f6f29..fa532b7 100644 --- a/DocOutput.cpp +++ b/DocOutput.cpp @@ -142,7 +142,7 @@ #ifdef _WIN32 -#include // for OutputDebugStringA +#include // for OutputDebugStringA static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void * /*user_data*/, int line, const char* file) { // DocOutputDevice* context = (DocOutputDevice*)user_data; diff --git a/DocTemplate.cpp b/DocTemplate.cpp index 37787cb..1b8a750 100644 --- a/DocTemplate.cpp +++ b/DocTemplate.cpp @@ -18,7 +18,7 @@ #ifndef _WIN32 # define HAVE_CONSTEXPR #else -# include +# include #endif #ifdef HAVE_CONSTEXPR diff --git a/Framework/GenericTableUI.h b/Framework/GenericTableUI.h index d7ca6d2..34bcb07 100644 --- a/Framework/GenericTableUI.h +++ b/Framework/GenericTableUI.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "GenericTable.h" @@ -75,7 +76,11 @@ { //for (int i = 0; i < m_genericTable->m_columnNames.size() - 1; i++) // m_view->horizontalHeader()->setSectionResizeMode(i, QHeaderView::ResizeToContents); +#if QT_VERSION >= 0x050000 m_view->horizontalHeader()->setSectionResizeMode((int)m_genericTable->m_columnNames.size() - 1, QHeaderView::Stretch); +#else + m_view->horizontalHeader()->setResizeMode((int)m_genericTable->m_columnNames.size() - 1, QHeaderView::Stretch); +#endif } } @@ -146,8 +151,10 @@ void reload() { +#if QT_VERSION >= 0x050000 beginResetModel(); endResetModel(); +#endif beginInsertRows(QModelIndex(), 0, (int)m_genericTable->size()); endInsertRows(); m_view->scrollToBottom(); diff --git a/Framework/Utilities.cpp b/Framework/Utilities.cpp index 22a00dc..65b023b 100644 --- a/Framework/Utilities.cpp +++ b/Framework/Utilities.cpp @@ -87,8 +87,8 @@ va_list args; va_start(args, a_format); #ifdef _WIN32 - auto sizeRequired = size_t(_vscprintf(a_format, args) + 1); - auto message = (char*)_alloca(sizeRequired); + size_t sizeRequired = size_t(_vscprintf(a_format, args) + 1); + char* message = (char*)_alloca(sizeRequired); _vsnprintf(message, sizeRequired, a_format, args); if (g_currentModule.m_messageLogger) g_currentModule.m_messageLogger->logMessage(a_logLevel, a_location, message); @@ -109,8 +109,8 @@ va_list args; va_start(args, a_format); #ifdef _WIN32 - auto sizeRequired = size_t(_vscprintf(a_format, args) + 1); - auto message = (char*)_alloca(sizeRequired); + size_t sizeRequired = size_t(_vscprintf(a_format, args) + 1); + char* message = (char*)_alloca(sizeRequired); _vsnprintf(message, sizeRequired, a_format, args); if (g_currentModule.m_errorHandler) g_currentModule.m_errorHandler->handleError(a_result, a_location, message); diff --git a/Framework/Utilities.h b/Framework/Utilities.h index 8db1c72..3741737 100644 --- a/Framework/Utilities.h +++ b/Framework/Utilities.h @@ -3,7 +3,7 @@ #include -#include +#include // mingw32 should be cstdint #include @@ -32,7 +32,10 @@ #define YQ_UNUSED(x) std::ignore = (x) -#ifdef _WIN32 +#ifdef __MINGW32__ +# define YQ_CALLBACK __cdecl +# define YQ_FUNCTION_NAME YQ_STRINGIZE(__func__) +#elif defined(_WIN32) // Avoid callbacks # define YQ_CALLBACK __cdecl # define YQ_FUNCTION_NAME __FUNCTION__ @@ -213,11 +216,24 @@ extern Module g_currentModule; +#ifdef NO_IS_POD +# define ASSERT_IS_POD(T, msg) +#else +# define ASSERT_IS_POD(T, msg) \ + static_assert(std::is_pod::value, msg); +#endif + + +#ifdef NO_NULLPTR +# define nullptr NULL +#endif + + // std::vector replacement that is cut down but familiar, uses the custom allocators, and restricted to POD elements only template struct PODArrayPOD // A dynamic array of POD type elements which is itself a POD type (so can have multi-dimensional arrays of these). { - static_assert(std::is_pod::value, "T must be a POD type."); + ASSERT_IS_POD(T, "T must be a POD type."); void init() { m_magic = 0x01020304; m_capacity = m_size = 0; m_data = nullptr; } void deinit() { if (m_data != nullptr) YQ_FREE(m_data); } @@ -247,16 +263,18 @@ }; -static_assert(std::is_pod >::value, "PODArrayPOD must be POD."); +ASSERT_IS_POD(PODArrayPOD, "PODArrayPOD must be a POD type."); template struct ArrayPOD // A dynamic array of POD type elements. It isn't POD itself, but is instead reference counted so safer to deal with. { - static_assert(std::is_pod::value, "T must be a POD type."); + ASSERT_IS_POD(T, "T must be a POD type."); +#ifndef NO_CPP11 ArrayPOD& operator=(const ArrayPOD&) = delete; ArrayPOD(const ArrayPOD&) = delete; +#endif ArrayPOD() { m_capacity = m_size = 0; m_data = nullptr; } ~ArrayPOD() { if (m_data != nullptr) YQ_FREE(m_data); } @@ -296,7 +314,7 @@ }; -static_assert(std::is_pod::value, "PODString must be POD."); +ASSERT_IS_POD(PODString, "PODString must be a POD type."); /* diff --git a/DocOutput.cpp b/DocOutput.cpp index d9f6f29..fa532b7 100644 --- a/DocOutput.cpp +++ b/DocOutput.cpp @@ -142,7 +142,7 @@ #ifdef _WIN32 -#include // for OutputDebugStringA +#include // for OutputDebugStringA static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void * /*user_data*/, int line, const char* file) { // DocOutputDevice* context = (DocOutputDevice*)user_data; diff --git a/DocTemplate.cpp b/DocTemplate.cpp index 37787cb..1b8a750 100644 --- a/DocTemplate.cpp +++ b/DocTemplate.cpp @@ -18,7 +18,7 @@ #ifndef _WIN32 # define HAVE_CONSTEXPR #else -# include +# include #endif #ifdef HAVE_CONSTEXPR diff --git a/Framework/GenericTableUI.h b/Framework/GenericTableUI.h index d7ca6d2..34bcb07 100644 --- a/Framework/GenericTableUI.h +++ b/Framework/GenericTableUI.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "GenericTable.h" @@ -75,7 +76,11 @@ { //for (int i = 0; i < m_genericTable->m_columnNames.size() - 1; i++) // m_view->horizontalHeader()->setSectionResizeMode(i, QHeaderView::ResizeToContents); +#if QT_VERSION >= 0x050000 m_view->horizontalHeader()->setSectionResizeMode((int)m_genericTable->m_columnNames.size() - 1, QHeaderView::Stretch); +#else + m_view->horizontalHeader()->setResizeMode((int)m_genericTable->m_columnNames.size() - 1, QHeaderView::Stretch); +#endif } } @@ -146,8 +151,10 @@ void reload() { +#if QT_VERSION >= 0x050000 beginResetModel(); endResetModel(); +#endif beginInsertRows(QModelIndex(), 0, (int)m_genericTable->size()); endInsertRows(); m_view->scrollToBottom(); diff --git a/Framework/Utilities.cpp b/Framework/Utilities.cpp index 22a00dc..65b023b 100644 --- a/Framework/Utilities.cpp +++ b/Framework/Utilities.cpp @@ -87,8 +87,8 @@ va_list args; va_start(args, a_format); #ifdef _WIN32 - auto sizeRequired = size_t(_vscprintf(a_format, args) + 1); - auto message = (char*)_alloca(sizeRequired); + size_t sizeRequired = size_t(_vscprintf(a_format, args) + 1); + char* message = (char*)_alloca(sizeRequired); _vsnprintf(message, sizeRequired, a_format, args); if (g_currentModule.m_messageLogger) g_currentModule.m_messageLogger->logMessage(a_logLevel, a_location, message); @@ -109,8 +109,8 @@ va_list args; va_start(args, a_format); #ifdef _WIN32 - auto sizeRequired = size_t(_vscprintf(a_format, args) + 1); - auto message = (char*)_alloca(sizeRequired); + size_t sizeRequired = size_t(_vscprintf(a_format, args) + 1); + char* message = (char*)_alloca(sizeRequired); _vsnprintf(message, sizeRequired, a_format, args); if (g_currentModule.m_errorHandler) g_currentModule.m_errorHandler->handleError(a_result, a_location, message); diff --git a/Framework/Utilities.h b/Framework/Utilities.h index 8db1c72..3741737 100644 --- a/Framework/Utilities.h +++ b/Framework/Utilities.h @@ -3,7 +3,7 @@ #include -#include +#include // mingw32 should be cstdint #include @@ -32,7 +32,10 @@ #define YQ_UNUSED(x) std::ignore = (x) -#ifdef _WIN32 +#ifdef __MINGW32__ +# define YQ_CALLBACK __cdecl +# define YQ_FUNCTION_NAME YQ_STRINGIZE(__func__) +#elif defined(_WIN32) // Avoid callbacks # define YQ_CALLBACK __cdecl # define YQ_FUNCTION_NAME __FUNCTION__ @@ -213,11 +216,24 @@ extern Module g_currentModule; +#ifdef NO_IS_POD +# define ASSERT_IS_POD(T, msg) +#else +# define ASSERT_IS_POD(T, msg) \ + static_assert(std::is_pod::value, msg); +#endif + + +#ifdef NO_NULLPTR +# define nullptr NULL +#endif + + // std::vector replacement that is cut down but familiar, uses the custom allocators, and restricted to POD elements only template struct PODArrayPOD // A dynamic array of POD type elements which is itself a POD type (so can have multi-dimensional arrays of these). { - static_assert(std::is_pod::value, "T must be a POD type."); + ASSERT_IS_POD(T, "T must be a POD type."); void init() { m_magic = 0x01020304; m_capacity = m_size = 0; m_data = nullptr; } void deinit() { if (m_data != nullptr) YQ_FREE(m_data); } @@ -247,16 +263,18 @@ }; -static_assert(std::is_pod >::value, "PODArrayPOD must be POD."); +ASSERT_IS_POD(PODArrayPOD, "PODArrayPOD must be a POD type."); template struct ArrayPOD // A dynamic array of POD type elements. It isn't POD itself, but is instead reference counted so safer to deal with. { - static_assert(std::is_pod::value, "T must be a POD type."); + ASSERT_IS_POD(T, "T must be a POD type."); +#ifndef NO_CPP11 ArrayPOD& operator=(const ArrayPOD&) = delete; ArrayPOD(const ArrayPOD&) = delete; +#endif ArrayPOD() { m_capacity = m_size = 0; m_data = nullptr; } ~ArrayPOD() { if (m_data != nullptr) YQ_FREE(m_data); } @@ -296,7 +314,7 @@ }; -static_assert(std::is_pod::value, "PODString must be POD."); +ASSERT_IS_POD(PODString, "PODString must be a POD type."); /* diff --git a/Util.h b/Util.h index 64a1094..bc6a8a5 100644 --- a/Util.h +++ b/Util.h @@ -1,6 +1,6 @@ #include -#ifndef _WIN32 +#ifndef _MSC_VER namespace std { diff --git a/DocOutput.cpp b/DocOutput.cpp index d9f6f29..fa532b7 100644 --- a/DocOutput.cpp +++ b/DocOutput.cpp @@ -142,7 +142,7 @@ #ifdef _WIN32 -#include // for OutputDebugStringA +#include // for OutputDebugStringA static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void * /*user_data*/, int line, const char* file) { // DocOutputDevice* context = (DocOutputDevice*)user_data; diff --git a/DocTemplate.cpp b/DocTemplate.cpp index 37787cb..1b8a750 100644 --- a/DocTemplate.cpp +++ b/DocTemplate.cpp @@ -18,7 +18,7 @@ #ifndef _WIN32 # define HAVE_CONSTEXPR #else -# include +# include #endif #ifdef HAVE_CONSTEXPR diff --git a/Framework/GenericTableUI.h b/Framework/GenericTableUI.h index d7ca6d2..34bcb07 100644 --- a/Framework/GenericTableUI.h +++ b/Framework/GenericTableUI.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "GenericTable.h" @@ -75,7 +76,11 @@ { //for (int i = 0; i < m_genericTable->m_columnNames.size() - 1; i++) // m_view->horizontalHeader()->setSectionResizeMode(i, QHeaderView::ResizeToContents); +#if QT_VERSION >= 0x050000 m_view->horizontalHeader()->setSectionResizeMode((int)m_genericTable->m_columnNames.size() - 1, QHeaderView::Stretch); +#else + m_view->horizontalHeader()->setResizeMode((int)m_genericTable->m_columnNames.size() - 1, QHeaderView::Stretch); +#endif } } @@ -146,8 +151,10 @@ void reload() { +#if QT_VERSION >= 0x050000 beginResetModel(); endResetModel(); +#endif beginInsertRows(QModelIndex(), 0, (int)m_genericTable->size()); endInsertRows(); m_view->scrollToBottom(); diff --git a/Framework/Utilities.cpp b/Framework/Utilities.cpp index 22a00dc..65b023b 100644 --- a/Framework/Utilities.cpp +++ b/Framework/Utilities.cpp @@ -87,8 +87,8 @@ va_list args; va_start(args, a_format); #ifdef _WIN32 - auto sizeRequired = size_t(_vscprintf(a_format, args) + 1); - auto message = (char*)_alloca(sizeRequired); + size_t sizeRequired = size_t(_vscprintf(a_format, args) + 1); + char* message = (char*)_alloca(sizeRequired); _vsnprintf(message, sizeRequired, a_format, args); if (g_currentModule.m_messageLogger) g_currentModule.m_messageLogger->logMessage(a_logLevel, a_location, message); @@ -109,8 +109,8 @@ va_list args; va_start(args, a_format); #ifdef _WIN32 - auto sizeRequired = size_t(_vscprintf(a_format, args) + 1); - auto message = (char*)_alloca(sizeRequired); + size_t sizeRequired = size_t(_vscprintf(a_format, args) + 1); + char* message = (char*)_alloca(sizeRequired); _vsnprintf(message, sizeRequired, a_format, args); if (g_currentModule.m_errorHandler) g_currentModule.m_errorHandler->handleError(a_result, a_location, message); diff --git a/Framework/Utilities.h b/Framework/Utilities.h index 8db1c72..3741737 100644 --- a/Framework/Utilities.h +++ b/Framework/Utilities.h @@ -3,7 +3,7 @@ #include -#include +#include // mingw32 should be cstdint #include @@ -32,7 +32,10 @@ #define YQ_UNUSED(x) std::ignore = (x) -#ifdef _WIN32 +#ifdef __MINGW32__ +# define YQ_CALLBACK __cdecl +# define YQ_FUNCTION_NAME YQ_STRINGIZE(__func__) +#elif defined(_WIN32) // Avoid callbacks # define YQ_CALLBACK __cdecl # define YQ_FUNCTION_NAME __FUNCTION__ @@ -213,11 +216,24 @@ extern Module g_currentModule; +#ifdef NO_IS_POD +# define ASSERT_IS_POD(T, msg) +#else +# define ASSERT_IS_POD(T, msg) \ + static_assert(std::is_pod::value, msg); +#endif + + +#ifdef NO_NULLPTR +# define nullptr NULL +#endif + + // std::vector replacement that is cut down but familiar, uses the custom allocators, and restricted to POD elements only template struct PODArrayPOD // A dynamic array of POD type elements which is itself a POD type (so can have multi-dimensional arrays of these). { - static_assert(std::is_pod::value, "T must be a POD type."); + ASSERT_IS_POD(T, "T must be a POD type."); void init() { m_magic = 0x01020304; m_capacity = m_size = 0; m_data = nullptr; } void deinit() { if (m_data != nullptr) YQ_FREE(m_data); } @@ -247,16 +263,18 @@ }; -static_assert(std::is_pod >::value, "PODArrayPOD must be POD."); +ASSERT_IS_POD(PODArrayPOD, "PODArrayPOD must be a POD type."); template struct ArrayPOD // A dynamic array of POD type elements. It isn't POD itself, but is instead reference counted so safer to deal with. { - static_assert(std::is_pod::value, "T must be a POD type."); + ASSERT_IS_POD(T, "T must be a POD type."); +#ifndef NO_CPP11 ArrayPOD& operator=(const ArrayPOD&) = delete; ArrayPOD(const ArrayPOD&) = delete; +#endif ArrayPOD() { m_capacity = m_size = 0; m_data = nullptr; } ~ArrayPOD() { if (m_data != nullptr) YQ_FREE(m_data); } @@ -296,7 +314,7 @@ }; -static_assert(std::is_pod::value, "PODString must be POD."); +ASSERT_IS_POD(PODString, "PODString must be a POD type."); /* diff --git a/Util.h b/Util.h index 64a1094..bc6a8a5 100644 --- a/Util.h +++ b/Util.h @@ -1,6 +1,6 @@ #include -#ifndef _WIN32 +#ifndef _MSC_VER namespace std { diff --git a/main.cpp b/main.cpp index be7a260..c5d5163 100644 --- a/main.cpp +++ b/main.cpp @@ -20,9 +20,14 @@ #ifndef _WIN32 # include # define __cdecl -int fopen_s(FILE** a_file, const char* a_fileName, const char* a_mode); #else -# include + extern "C" void __stdcall Sleep(unsigned int); +//# include +#endif + + +#ifndef _MSC_VER // _WIN32 +int fopen_s(FILE** a_file, const char* a_fileName, const char* a_mode); #endif @@ -179,6 +184,14 @@ int main(int argc, char* argv[]) { + fprintf(stderr, "HERE!\n\n\n"); + QApplication app2(argc, argv); + QLabel l(0); + l.setText("Hello!"); + l.show(); + app2.exec(); + + DocOutputDevice outputDoc; Context context = { "Test Markdown to PDF", diff --git a/DocOutput.cpp b/DocOutput.cpp index d9f6f29..fa532b7 100644 --- a/DocOutput.cpp +++ b/DocOutput.cpp @@ -142,7 +142,7 @@ #ifdef _WIN32 -#include // for OutputDebugStringA +#include // for OutputDebugStringA static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void * /*user_data*/, int line, const char* file) { // DocOutputDevice* context = (DocOutputDevice*)user_data; diff --git a/DocTemplate.cpp b/DocTemplate.cpp index 37787cb..1b8a750 100644 --- a/DocTemplate.cpp +++ b/DocTemplate.cpp @@ -18,7 +18,7 @@ #ifndef _WIN32 # define HAVE_CONSTEXPR #else -# include +# include #endif #ifdef HAVE_CONSTEXPR diff --git a/Framework/GenericTableUI.h b/Framework/GenericTableUI.h index d7ca6d2..34bcb07 100644 --- a/Framework/GenericTableUI.h +++ b/Framework/GenericTableUI.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "GenericTable.h" @@ -75,7 +76,11 @@ { //for (int i = 0; i < m_genericTable->m_columnNames.size() - 1; i++) // m_view->horizontalHeader()->setSectionResizeMode(i, QHeaderView::ResizeToContents); +#if QT_VERSION >= 0x050000 m_view->horizontalHeader()->setSectionResizeMode((int)m_genericTable->m_columnNames.size() - 1, QHeaderView::Stretch); +#else + m_view->horizontalHeader()->setResizeMode((int)m_genericTable->m_columnNames.size() - 1, QHeaderView::Stretch); +#endif } } @@ -146,8 +151,10 @@ void reload() { +#if QT_VERSION >= 0x050000 beginResetModel(); endResetModel(); +#endif beginInsertRows(QModelIndex(), 0, (int)m_genericTable->size()); endInsertRows(); m_view->scrollToBottom(); diff --git a/Framework/Utilities.cpp b/Framework/Utilities.cpp index 22a00dc..65b023b 100644 --- a/Framework/Utilities.cpp +++ b/Framework/Utilities.cpp @@ -87,8 +87,8 @@ va_list args; va_start(args, a_format); #ifdef _WIN32 - auto sizeRequired = size_t(_vscprintf(a_format, args) + 1); - auto message = (char*)_alloca(sizeRequired); + size_t sizeRequired = size_t(_vscprintf(a_format, args) + 1); + char* message = (char*)_alloca(sizeRequired); _vsnprintf(message, sizeRequired, a_format, args); if (g_currentModule.m_messageLogger) g_currentModule.m_messageLogger->logMessage(a_logLevel, a_location, message); @@ -109,8 +109,8 @@ va_list args; va_start(args, a_format); #ifdef _WIN32 - auto sizeRequired = size_t(_vscprintf(a_format, args) + 1); - auto message = (char*)_alloca(sizeRequired); + size_t sizeRequired = size_t(_vscprintf(a_format, args) + 1); + char* message = (char*)_alloca(sizeRequired); _vsnprintf(message, sizeRequired, a_format, args); if (g_currentModule.m_errorHandler) g_currentModule.m_errorHandler->handleError(a_result, a_location, message); diff --git a/Framework/Utilities.h b/Framework/Utilities.h index 8db1c72..3741737 100644 --- a/Framework/Utilities.h +++ b/Framework/Utilities.h @@ -3,7 +3,7 @@ #include -#include +#include // mingw32 should be cstdint #include @@ -32,7 +32,10 @@ #define YQ_UNUSED(x) std::ignore = (x) -#ifdef _WIN32 +#ifdef __MINGW32__ +# define YQ_CALLBACK __cdecl +# define YQ_FUNCTION_NAME YQ_STRINGIZE(__func__) +#elif defined(_WIN32) // Avoid callbacks # define YQ_CALLBACK __cdecl # define YQ_FUNCTION_NAME __FUNCTION__ @@ -213,11 +216,24 @@ extern Module g_currentModule; +#ifdef NO_IS_POD +# define ASSERT_IS_POD(T, msg) +#else +# define ASSERT_IS_POD(T, msg) \ + static_assert(std::is_pod::value, msg); +#endif + + +#ifdef NO_NULLPTR +# define nullptr NULL +#endif + + // std::vector replacement that is cut down but familiar, uses the custom allocators, and restricted to POD elements only template struct PODArrayPOD // A dynamic array of POD type elements which is itself a POD type (so can have multi-dimensional arrays of these). { - static_assert(std::is_pod::value, "T must be a POD type."); + ASSERT_IS_POD(T, "T must be a POD type."); void init() { m_magic = 0x01020304; m_capacity = m_size = 0; m_data = nullptr; } void deinit() { if (m_data != nullptr) YQ_FREE(m_data); } @@ -247,16 +263,18 @@ }; -static_assert(std::is_pod >::value, "PODArrayPOD must be POD."); +ASSERT_IS_POD(PODArrayPOD, "PODArrayPOD must be a POD type."); template struct ArrayPOD // A dynamic array of POD type elements. It isn't POD itself, but is instead reference counted so safer to deal with. { - static_assert(std::is_pod::value, "T must be a POD type."); + ASSERT_IS_POD(T, "T must be a POD type."); +#ifndef NO_CPP11 ArrayPOD& operator=(const ArrayPOD&) = delete; ArrayPOD(const ArrayPOD&) = delete; +#endif ArrayPOD() { m_capacity = m_size = 0; m_data = nullptr; } ~ArrayPOD() { if (m_data != nullptr) YQ_FREE(m_data); } @@ -296,7 +314,7 @@ }; -static_assert(std::is_pod::value, "PODString must be POD."); +ASSERT_IS_POD(PODString, "PODString must be a POD type."); /* diff --git a/Util.h b/Util.h index 64a1094..bc6a8a5 100644 --- a/Util.h +++ b/Util.h @@ -1,6 +1,6 @@ #include -#ifndef _WIN32 +#ifndef _MSC_VER namespace std { diff --git a/main.cpp b/main.cpp index be7a260..c5d5163 100644 --- a/main.cpp +++ b/main.cpp @@ -20,9 +20,14 @@ #ifndef _WIN32 # include # define __cdecl -int fopen_s(FILE** a_file, const char* a_fileName, const char* a_mode); #else -# include + extern "C" void __stdcall Sleep(unsigned int); +//# include +#endif + + +#ifndef _MSC_VER // _WIN32 +int fopen_s(FILE** a_file, const char* a_fileName, const char* a_mode); #endif @@ -179,6 +184,14 @@ int main(int argc, char* argv[]) { + fprintf(stderr, "HERE!\n\n\n"); + QApplication app2(argc, argv); + QLabel l(0); + l.setText("Hello!"); + l.show(); + app2.exec(); + + DocOutputDevice outputDoc; Context context = { "Test Markdown to PDF", diff --git a/ui.h b/ui.h index 2074e52..6398374 100644 --- a/ui.h +++ b/ui.h @@ -41,7 +41,9 @@ g_currentModule.m_messageLogger = &logger; appWindow.setupUi(&mainWindow); +#if QT_VERSION >= 0x050000 mainWindow.menuBar()->setNativeMenuBar(false); +#endif about.setupUi(&aboutDialog); aboutDialog.setFixedSize(430, 300);