xiaoyeli / superlu

Supernodal sparse direct solver. https://portal.nersc.gov/project/sparse/superlu/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can not open “unistd.h” for Visual Studio on Windows

adam-sim-dev opened this issue · comments

In zdriver

This is a Unix header. You can install Cygwin or MinGW to get it on Windows, too.

This is a Unix header. You can install Cygwin or MinGW to get it on Windows, too.

Which functions are included in this header? Can they be replaced by stand C functions?

That is a good question.
a) unistd.h is only used in examples and tests. SuperLU itself should work without this header.
b) Removing or replacing unistd.h does not solve the problem, getopt.h is also a header that is not provided by Windows. It is also only used in examples and tests.
c) From a quick test I believe, that both headers are used to get the function getopt to parse command line arguments. It might be possible to include an implementation of getopt in SuperLU and remove both headers.

@xiaoyeli what do you think, should I prepare an merge request doing c)? This would increase the portability to Windows.

@gruenich if you can implement getopt, that would be good.

I'll have a look.

There's https://github.com/alex85k/wingetopt already.

That's what I'm using and it works flawlessly with my PR #107

@xiaoyeli The unistd.h header was introduced in a49ee5f Add #include <unistd.h> in EXAMPLE files, to get prototype for getopt().

For testing purpose, I removed all the includes from the examples and they build just fine (Arch, GCC 13.1.1). Were there any errors on other platforms which led to the decision to include the header. Shouldn't the include of getopt.h be enough?

EDIT:
The same goes for the tests and math.h. The math header is included, but I haven't found any math functions being used. Most of the time it is included like

#include <math.h>
#include "slu_ddefs.h"

but math.h also gets included in the slu_[x]defs.h header, so no need to include it again.

Let me know, if I should clean this up in my current pull request.

Removed unistd.h