Skip to content

Commit 0fca8b7

Browse files
committed
Windows compatibility
1 parent 8627996 commit 0fca8b7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/ChunkInfo.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@
2626
#include <iostream>
2727
#include <list>
2828
#include <map>
29-
#include <unistd.h>
3029
#include <utility>
3130

31+
#ifdef _WIN32
32+
#include <windows.h>
33+
#else
34+
#include <unistd.h>
35+
#endif
36+
3237
namespace openPMD
3338
{
3439
ChunkInfo::ChunkInfo( Offset offset_in, Extent extent_in )
@@ -569,7 +574,10 @@ chunk_assignment::RankMeta byMethodCollective( MPI_Comm comm, Method method )
569574
std::string hostname()
570575
{
571576
char hostname[ MAX_HOSTNAME_LENGTH ];
572-
gethostname( hostname, MAX_HOSTNAME_LENGTH );
577+
if( gethostname( hostname, MAX_HOSTNAME_LENGTH ) )
578+
{
579+
throw std::runtime_error( "[gethostname] Could not inquire hostname." );
580+
}
573581
std::string res( hostname );
574582
return res;
575583
}

0 commit comments

Comments
 (0)