Unix to Windows Porting Dictionary for HPC

Links

Function List

close


Unix

header file: unistd.h

int close(int fd);

Windows

header file: io.h

int _close(int fd);

Purpose

This function deallocates the file descriptor named in the parameter.

Discussion

Since this function has a one-to-one correspondence with the _close function in Windows, there should not be any other changes required other than renaming the function and including the header file. Note that if a file was opened with fopen(), it should be closed with fclose(), rather than _close().

Example of Use in Windows

#include <io.h>

int error;
error = _close(my_file_fd));
if (error)
  printf("File is closed.");
else
  printf("_close failed with error number %d", error);
  
blog comments powered by Disqus