Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling under MINGW-w64/MSYS2 #11

Closed
mcleinn opened this issue Jan 5, 2022 · 8 comments
Closed

Compiling under MINGW-w64/MSYS2 #11

mcleinn opened this issue Jan 5, 2022 · 8 comments
Assignees

Comments

@mcleinn
Copy link

mcleinn commented Jan 5, 2022

...works after adding the following at the beginning of fftgen.cpp

#ifdef __MINGW32__
#include <direct.h> // mkdir
#define mkdir(A,B)  _mkdir(A)
#define lstat(p,s)   stat(p,s)
#endif
@mcleinn mcleinn changed the title Compiling under MING2 Compiling under MINGW Jan 5, 2022
@mcleinn mcleinn changed the title Compiling under MINGW Compiling under MINGW-w64/MSYS2 Jan 5, 2022
@ZipCPU ZipCPU self-assigned this Jan 6, 2022
@ZipCPU
Copy link
Owner

ZipCPU commented Jan 6, 2022

You realize, I could apply this patch but I won't be able to test it.

Let me just ask, is it working for you?

Dan

@ZipCPU
Copy link
Owner

ZipCPU commented Jan 6, 2022

Try the core generator now. As far as I can tell, this should (now) be fixed.

Dan

@mcleinn
Copy link
Author

mcleinn commented Jan 6, 2022

Sorry, it does not work for me like that. The current code produces a lot of errors, and it does not seem to go into the IF clause at all. However, the code compiles when I remove the #elif defined(__MINGW32__) clause, and put the code

#ifdef __MINGW32__
#include <direct.h> // mkdir
#define mkdir(A,B)  _mkdir(A)
#define lstat(p,s)   stat(p,s)
#endif

before the #ifdef _MSC_VER in line 67

Please note that there is a comment about "Macintosh environment" in your code.
If this refers to MINGW-w64/MSYS2, this would not be correct. MINGW-w64/MSYS2 is a Unix-style open source development platform for Windows, which is popular with the open hardware crowd.

To answer to your first question, yes, adding this code removes all issues and lets me run the generator.

@ZipCPU
Copy link
Owner

ZipCPU commented Jan 7, 2022

This isn't for the Mac? My bad then.

If the "elif" isn't getting acted on, then is the prior "ifdef" what's getting run or the one following? If the one following, then ... is that because the "__MINGW32__" macro I used isn't defined?

The reason why I rewrote the code from what you gave me is because I needed to. I've now got three separate operating environments, all different, all of which need to be supported, and no two of which should ever be true together. Hence the need for the 3-way "if" statement.

Would it work if the "ifdef _MSC_VER" was adjusted to "#if defined(_MSC_VER)"? That should be valid C preprocessor syntax--although what's there should be valid syntax too. I'd be quite curious to know why it isn't running for you.

Dan

@mcleinn
Copy link
Author

mcleinn commented Jan 7, 2022

Turns out the problem is not with the preprocessor syntax.
The problem is that MINGW is a Linux-style environment, and it requires the includes you included for Linux in the "#else" part.
The following compiles:

#elif defined(__MINGW32__) 
// MinGW - Minimalist GNU for Windows - also MinGW-w64/MSYS2
// {{{
#include <direct.h>	// mkdir
#define	mkdir(A,B)	_mkdir(A)
#define	lstat(p,s)	stat(p,s)
#include <unistd.h>	// Defines the R_OK/W_OK/etc. macros
#include <sys/stat.h>
// }}}
#else

@ZipCPU
Copy link
Owner

ZipCPU commented Jan 7, 2022

Ok, patched. Please give it a test and tell me if it works. (It should ...)

Dan

@mcleinn
Copy link
Author

mcleinn commented Jan 7, 2022

Yes, I can confirm that the current version compiles without problems. Thank you

@ZipCPU
Copy link
Owner

ZipCPU commented Jan 7, 2022

Awesome! Thank you for your help. I'm sure others using MinGW thank you as well.

Closing this issue.

Dan

@ZipCPU ZipCPU closed this as completed Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants