Skip to content

Commit

Permalink
Removal of warnings if when using make(mingw32/64)
Browse files Browse the repository at this point in the history
In order to ensure that JPEGoptim is compiled warning-free (since some environments refuse to compile on warning), I have added a check if S_ISREG and S_ISDIR are already defined, since they're being defined already in mingw32s stat.h file: 

Line 165:0 : #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
Which is identical to the function we have here:
Line 35:0 : #define S_ISDIR(mode)  (((mode) & S_IFMT) == S_IFDIR)

The same applies to S_ISREG, at line 169 in mingws stat.h and at line 34 in this file.

A possible different approach to get rid of the warnings would be to #undef the function and just redefine it, which might look nasty but ensures that this implementation of the function is used.

In addition to these, mingw doesn't like the "#else if" statement, which should be an "#elif" statement (Line 40:7)
  • Loading branch information
Waldemar M authored Oct 17, 2017
1 parent c9146e6 commit cf8ac04
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion win32_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ extern "C" {
#define getuid(x) 0
#define geteuid() 0
#define chown(outfname,st_uid,st_gid) 0

#ifndef S_ISREG
#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
#endif

#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#endif

#ifndef HOST_TYPE
#if _WIN64
#define HOST_TYPE "Win64"
#else if WIN32
#elif WIN32
#define HOST_TYPE "Win32"
#endif
#endif
Expand Down

0 comments on commit cf8ac04

Please sign in to comment.