Page 3 of 4

Re: [Patch] New Makefile

PostPosted: Sun Jan 21, 2018 8:13 am
by Ian
Well I had a go at cleaning up the header files. Hopefully included your changes as well

Code: Select all
using namespace Debugger;
// TODO - can't get this namespace to work with 68K.h for some reason - strange Visual Studio errors
//namespace Debugger
//{


in Musashi68KDebug.h
still needs to be looked at

Re: [Patch] New Makefile

PostPosted: Sun Jan 21, 2018 8:44 am
by HarryTuttle
Ian, I made some progress: there was a name conflict between "\Src\Debugger\IO.h" and a same named file in mingw32 system headers. I think during compilation, probably, the former took precedence over the latter in some way and, as a side effect, "_chsize" remained undefined, where usually is defined at system level. Plus many other things consequentially broke.

I resolved all by:
- renaming "IO.cpp" to "DebuggerIO.cpp"
- renaming "IO.h" to "DebuggerIO.h"
- change accordingly every reference to that file.

It remains only a "bug": if I compile with both ENABLE_DEBUGGER and NET_BOARD set then at link time it throws out this:
Code: Select all
_obj/CPUDebug.o:CPUDebug.cpp:(.text+0x8df): undefined reference to `CThread::CreateMutex()'
_obj/Debugger.o:Debugger.cpp:(.text+0x1408): undefined reference to `CThread::CreateMutex()'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefiles/Makefile.inc:288: _bin/supermodel] Error 1
make: Target 'all' not remade because of errors.

Now it behaves in all aspects like the old makefile, bug included. Probably the changed compile/link order from the older one made a difference.

I'll post the final patch in few minutes, however someone should rename those two files in the repository.

Re: [Patch] New Makefile

PostPosted: Sun Jan 21, 2018 8:51 am
by Ian
It shouldn't be possible for headers to conflict like that ..
Check maybe for a redefining of this

INCLUDED_IO_H

CThread::CreateMutex()
Could be failing if windows.h is included first because it has a macro for CreateMutex i think

simply
#ifdef _WIN32
#undef CreateMutex
#endif

might work

Re: [Patch] New Makefile

PostPosted: Sun Jan 21, 2018 9:10 am
by HarryTuttle
Ian wrote:It shouldn't be possible for headers to conflict like that ..
Check maybe for a redefining of this

INCLUDED_IO_H

Actually, I've done that too.
EDIT: it seems that name also matters, otherwise it won't compile. I'm posting the patch.

Ian wrote:simply
#ifdef _WIN32
#undef CreateMutex
#endif

might work

I'll try that

Re: [Patch] New Makefile

PostPosted: Sun Jan 21, 2018 9:48 am
by HarryTuttle
PATCH for r705:

- Updated makefiles to support the various compile options: internal debugger, debug mode, new frame sync, net board. For example launch with "make -f Makefile.Win32 ENABLE_DEBUGGER=1"

- Tested only under MSYS2 and Windows 7 x64. On this OS it should automatically check for 64 or 32 bit OS type. Also it should use the appropriate delete console command when cleaning ("rmdir" for Windows prompt, "rm" for Bash)

- Renamed every reference to "IO[.h|.cpp]" into "DebuggerIO[.h|.cpp]" and made other changes to IO.h as it caused some problem during compilation when ENABLE_DEBUGGER was set

- Updated "UDPSend.cpp" to support inet_pton() function under MinGW/GCC

If using MinGW, before applying the patch, it's important to manually rename "\Src\Debugger\IO[.h|.cpp]" into "\Src\Debugger\DebuggerIO[.h|.cpp]", at least until the names stay as they are in the official repository.

There's still a compile issue with both ENABLE_DEBUGGER and NET_BOARD set, I'm investigating. EDIT: Fixed with addendum #2

Re: [Patch] New Makefile

PostPosted: Sun Jan 21, 2018 10:44 am
by HarryTuttle
PATCH Addendum #1 (Ian that's for you):

- Some more "using namespace std" removal

Re: [Patch] New Makefile

PostPosted: Sun Jan 21, 2018 11:21 am
by HarryTuttle
PATCH Addendum #2:

- Fix link error when compiling with both ENABLE_DEBUGGER and NET_BOARD set

Re: [Patch] New Makefile

PostPosted: Mon Jan 22, 2018 5:19 am
by Ian
I'll try push these tonight
I don't use makefiles so may need Bart to have a look at those

Using namespaces is totally fine. But doing it in header files can cause some painful unwanted side effects.

Re: [Patch] New Makefile

PostPosted: Mon Jan 22, 2018 11:26 am
by Ian
Harry,
does your compiler support
https://msdn.microsoft.com/en-us/librar ... 63(v=vs.85).aspx
inet_addr
?

Re: [Patch] New Makefile

PostPosted: Mon Jan 22, 2018 11:39 am
by HarryTuttle


From what I've just read it should as long as I link with libwsock32 and libws2_32.