I am using the code example shown in post 592448 to try grant full file permisison. When I compile the code snippet using:
gcc -shared -mno-cygwin -Wall -o native.dll native.c
I get below error:
native.c:8: error: conflicting types for 'mode_t'
/usr/i686-pc-mingw32/sys-root/mingw/include/sys/types.h:99: error: previous declaration of 'mode_t' was here
native.c:21: error: parse error before numeric constant
native.c:22: error: parse error before numeric constant
native.c:23: error: parse error before numeric constant
native.c:25: error: parse error before "mode_t"
native.c:26: error: parse error before "mode_t"
native.c:28: error: parse error before "mode_t"
native.c:29: error: parse error before "mode_t"
I stripped the code down to reduce to below, which compiles fine but do not seem to change the file permission as required.
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#ifdef _WIN32
# include <io.h>
typedef signed int md_t;
static const md_t MS_MODE_MASK = 0x0000ffff; ///< low word
int fchmod(const char * path, md_t mode)
{
int result = _chmod(path, (mode & MS_MODE_MASK));
if (result != 0)
{
result = errno;
}
return (result);
}
#else
int fchmod(const char * path, md_t mode)
{
int result = chmod(path, mode);
if (result != 0)
{
result = errno;
}
return (result);
}
#endif
Any pointers on how to get this working?
Note that on windows all this can do is set the file to readonly or not, Windows file permissions are different from UNIX type file permissions.
If this is all you want to do: in what way is it not working?
EDIT: regarding the initial error you had
mode_tdefined elsewhere:/usr/i686-pc-mingw32/sys-root/mingw/include/sys/types.h:99and tried to redefine it astypedef int mode_t;from MSDN: