dbsoft / dwindows

Dynamic Windows Library Mirror
Other
8 stars 1 forks source link

dwcompat.h is the source of problems #3

Closed ghost closed 2 years ago

ghost commented 2 years ago

In dwtest.c:

/* For snprintf, strdup etc on old Windows SDK */
#if defined(__WIN32__) || defined(__OS2__)
#include "dwcompat.h"
#endif

I wanted to know how old these Windows SDKs are for dwcompat to be required. I'm using MinGW-W64 and dwcompat.h is causing problems. Comment out the block of code above solved it.

dbsoft commented 2 years ago

If memory serves those functions in old versions of MSVCRT are only available as _snprintf, _strdup etc ... so I have macros in dwcompat.h that point snprintf strdup etc to them... I don't remember which are which... but dwcompat.h may require changes to be C++ compatible if that is what this issue is relating to.

ghost commented 2 years ago

If memory serves those functions in old versions of MSVCRT are only available as _snprintf, _strdup etc ... so I have macros in dwcompat.h that point snprintf strdup etc to them... I don't remember which are which... but dwcompat.h may require changes to be C++ compatible if that is what this issue is relating to.

No. This is not related to C++. I compiled dwtest.c with gcc from MinGW-W64 and it fails, after commenting out dwcompat.h it now compiled and run fine. Maybe you should add a macro in dwtest.c to check for MinGW-W64, if it's MinGW-W64's gcc then don't include dwcompat.h. This macro could be served as a template for us to copy to our own source file too.

peprnp commented 2 years ago

To check for MINGW-W64 you could check for the macro __MINGW32__ (which is defined for both 32 bit and 64 bit version of MINGW-W64). As I know the macro __MINGW64__ is only defined on MINGW-W64 64 bit and the macro __MINGW__ is not defined at all (doesn't sure about that, you could check it yourself).

dbsoft commented 2 years ago

MINGW64 is one of the compilers I test with, not sure why it wouldn't compile.. but I'll double check it when I get some time later this week. There are a number of variations of that compiler though, can you tell me which one specifically you are using? I think I was using the TDM version: https://jmeubank.github.io/tdm-gcc/download/

dbsoft commented 2 years ago

I tested with a newer version of MingW64, it seems that _MSC_VER is no longer defined, so I added MINGW32 check as well. See if the latest commit fixes it. Forgot to mention this issue in the commit though.

https://github.com/dbsoft/dwindows/commit/2c5e4be5da6b85f2d9ccf61c56f6c5505782cbe8

ghost commented 2 years ago

I tested with a newer version of MingW64, it seems that _MSC_VER is no longer defined, so I added MINGW32 check as well. See if the latest commit fixes it. Forgot to mention this issue in the commit though.

2c5e4be

Please have a look at line 274 of dwcompat.h, you forgot to add the MinGW-W64 check here. Change it to this fixed the problem: #if !defined(_MSC_VER) && !defined(__MINGW32__)

dbsoft commented 2 years ago

Please have a look at line 274 of dwcompat.h, you forgot to add the MinGW-W64 check here. Change it to this fixed the problem: #if !defined(_MSC_VER) && !defined(__MINGW32__)

That is what I changed it to. Did it not work for you?

ghost commented 2 years ago

Please have a look at line 274 of dwcompat.h, you forgot to add the MinGW-W64 check here. Change it to this fixed the problem: #if !defined(_MSC_VER) && !defined(__MINGW32__)

That is what I changed it to. Did it not work for you?

Sorry. I forgot to replace the dwcompat.h in your 3.2 release with the latest from github :smile:

dbsoft commented 2 years ago

Ok, going to close this issue then... if there is anything else feel free to reopen it!