aardappel / procrastitracker

a Windows time tracking application
http://strlen.com/procrastitracker/
500 stars 53 forks source link

Mingw #24

Closed jt-fuw closed 7 years ago

jt-fuw commented 7 years ago

Needs fix for mousewheel, otherwise MinGW g++ shows compilation error.

To compile, set PATH to MinGW binaries, enter 'src' directory and type 'make'.

Except fix for mousewheel in src/IdleTracker.cpp the following changes were done: src/Makefile - new src/ddeutil.h - no CALLBACK before WinEventProc() if MINGW32_BUG defined src/node.h - v.sort() arg type casted to void*; added {} to avoid forward goto within block src/procrastitracker.cpp - sprintf_s defined as snprintf (MinGW only) src/procrastitracker.cpp - 2X type specified where 'auto' type was used src/procrastitracker.cpp - SetTimer arg2 0 instead NULL if MINGW32_BUG defined src/statview.h - max() macro and struct tagTVKEYDOWN defined (MinGW only) src/stdafx.h - removed #include src/timercallback.h - 1X type specified where 'auto' type was used src/tools.h - min() macro defined (MinGW only)

"MinGW only" means detecting MINGW32 using ifdef

Tested on Windows XP SP3 - compiles, runs, shows user action statistics. Two changes assumed to be workaround for MinGW bugs (type definition in MinGW header files do not match the same object type in MSDN docs).

jt-fuw commented 7 years ago

src/procrastitracker.cpp - auto

leave out the auto entirely OK

src/procrastitracker.cpp - SetTimer

just_ use 0 on both _platforms? https://msdn.microsoft.com/pl-pl/library/windows/desktop/ms644906(v=vs.85).aspx UINT_PTR WINAPI SetTimer( _Inopt HWND hWnd, In UINT_PTR nIDEvent, In UINT uElapse, _Inopt TIMERPROC lpTimerFunc ); MinGW:include/winuser.h WINUSERAPI UINT WINAPI SetTimer(HWND,UINT,UINT,TIMERPROC);

Note on MSDN arg 2 is pointer, in MinGW header it is UINT; I consider it MinGW bug.

src/node.h

keep style of surrounding code: space between void and * OK

src/Makefile

Add some comments at the top to indicate that this is to compile PT with mingw OK

src/IdleTracker.cpp

these changes have already gone in, so you'll need to rebase against new master. Yes, I know; I just didn't know how to do it - I am new to GitHub.

src/statview.h and src/tools.h

use of std::max would be even better, if mingw has it. MinGW has max() and min() definitions in windef.h - is it in MS Visual Studio? I haven't found std::max in MinGW headers - maybe it needs installation of some extra package, Ubuntu Linux g++ needs libstdc++ package for it. Add just #include (unconditionally) or it can harm for MS VS?

aardappel commented 7 years ago

btw, you can comment on each of my comments individually.

and yes, on MSVC you have by default min/max if windows.h is included, which it already does in stdafx.h.. you can add windef.h there if it doesn't already do this for you.

jt-fuw commented 7 years ago

I changed min() and max() to std::min() and std::max() and it works in MinGW (without extra define-s or include-s); in MS Visual Studio too?

I tried adding definition: static int nodesorter(node _a, node _b); in node.h, but it caused compilation errors. So the typecasting remains (I added the space in (void *)).

The NMTVKEYDOWN type is new name of TV_KEYDOWN (by MSDN since Windows Vista) - MinGW still uses old name. Therefore my newer version of statview.h refers the old name instead defining the structure again (typedef TV_KEYDOWN NMTVKEYDOWN, *LPNMTVKEYDOWN).

I removed 'auto' everywhere and added comments to Makefile. But I am not sure if newest version of all files are on GitHub now, I will check in tonight.

jt-fuw commented 7 years ago

I tested exactly the 'mingw' branch, compiled using MinGW g++ - it is working.

And I changes base branch (or at least I tried to do it - note I am novice here), according to: https://help.github.com/articles/changing-the-base-branch-of-a-pull-request/ At least 'Compare' shows differences between your actual files and my in 'mingw' branch.

Can you please verify my actual files can be compiled by the MS Visual Studio you use?

I tested again the node.h - moved nodesorter() to be defined before its use, and found for MinGW v.sort() must have arg type (void *) - so I will remove the declaration of it.

And I asked a friend to try compiling this source with an older MS Visual Studio (2008, if I recall correctly) - I would like to know the 2015 version is not the only which compiles it. But she cannot do it tonight, so I must wait.

And finally I need to add few words to readme.md - that it can be compiled using MinGW.

aardappel commented 7 years ago

It looks good so far. I'll merge it, and if something doesn't compile with VS2015 I'll fix it.

aardappel commented 7 years ago

had to make this small fix: https://github.com/aardappel/procrastitracker/commit/38c2cc5d4aed1bbfae7236e274746f1bf897cbb2