Skip to content
This repository has been archived by the owner on Apr 17, 2022. It is now read-only.

fix MXE compiler warnings #4753

Closed
wzdev-ci opened this issue Feb 22, 2018 · 16 comments
Closed

fix MXE compiler warnings #4753

wzdev-ci opened this issue Feb 22, 2018 · 16 comments

Comments

@wzdev-ci
Copy link
Contributor

resolution_fixed type_patch (an actual patch, not a request for one) | by Forgon


MXE ensures that all code is position-independent. Warzone 2100 uses the "-fPIC" compile flag, leading to several unnecessary warnings like:

connecthostport.c:1:0: warning: -fPIC ignored for target (all code is position independent)
 /* $Id: connecthostport.c,v 1.15 2015/10/09 16:26:19 nanard Exp $ */
 ^

GCC developers expect users not use "-fPIC" for Windows targets. Consequently, we no longer do.


The MSVC-specific pragma "comment" was executed on other platforms and thus not recognised:

In file included from uECC.c:84:0:
platform-specific.inc:12:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(lib, "crypt32.lib")
 ^
platform-specific.inc:13:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(lib, "advapi32.lib")
 ^

The format specifier macros 'PRIu32', 'PRIu64' and 'PRId64' were not properly expanded with MXE, causing warnings such as:

In file included from string_ext.h:24:0,
                 from frame.h:44,
                 from trig.h:29,
                 from trig.cpp:31:
trig.cpp: In function 'bool trigInitialise()':
debug.h:71:58: warning: unknown conversion type character 'l' in format [-Wformat=]
    (void)_debug(__LINE__, LOG_INFO, function, __VA_ARGS__), \
                                                          ^
debug.h:98:4: note: in expansion of macro 'ASSERT_FAILURE'
    ASSERT_FAILURE(expr, #expr, location_description, function, __VA_ARGS__) \
    ^
debug.h:109:2: note: in expansion of macro 'ASSERT_HELPER'
  ASSERT_HELPER(expr, AT_MACRO, __FUNCTION__, __VA_ARGS__)
  ^
trig.cpp:76:3: note: in expansion of macro 'ASSERT'
   ASSERT((uint32_t)iSqrt(lower) == test, "Sanity check failed, sqrt(%" PRIu64") gave %" PRIu32" instead of %" PRIu64"!", lower, i64Sqrt(lower), test);
   ^
debug.h:71:58: warning: format '%u' expects argument of type 'unsigned int', but argument 5 has type 'uint64_t {aka long long unsigned int}' [-Wformat=]
    (void)_debug(__LINE__, LOG_INFO, function, __VA_ARGS__), \
                                                          ^
debug.h:98:4: note: in expansion of macro 'ASSERT_FAILURE'
    ASSERT_FAILURE(expr, #expr, location_description, function, __VA_ARGS__) \
    ^
debug.h:109:2: note: in expansion of macro 'ASSERT_HELPER'
  ASSERT_HELPER(expr, AT_MACRO, __FUNCTION__, __VA_ARGS__)
  ^
trig.cpp:76:3: note: in expansion of macro 'ASSERT'
   ASSERT((uint32_t)iSqrt(lower) == test, "Sanity check failed, sqrt(%" PRIu64") gave %" PRIu32" instead of %" PRIu64"!", lower, i64Sqrt(lower), test);
   ^

The solution was to use the MXE-specific macros '!__USE_MINGW_ANSI_STDIO' and '!__MINGW_PRINTF_FORMAT' as described here.


A typo caused this warning:

frontend.cpp:175:27: warning: multi-character character constant [-Wmultichar]
  wchar_t  wszDest[250] = {'/0'};
                           ^

Parentheses were added around assignments used as truth values to avoid compiler warnings like:

exchndl.cpp: In function 'void ExchndlSetup(const char*)':
exchndl.cpp:1375:61: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  if (dwRetVal = GetCurrentDirectoryW(MAX_PATH, miniDumpPath))
                                                             ^

Issue migrated from trac:4753 at 2022-04-16 13:03:45 -0700

@wzdev-ci
Copy link
Contributor Author

Forgon uploaded file fpic_windows.patch (1.1 KiB)

patch file created with git format-patch (part 1/5)

@wzdev-ci
Copy link
Contributor Author

Forgon uploaded file msvc_pragma.patch (0.8 KiB)

patch file created with git format-patch (part 2/5)

@wzdev-ci
Copy link
Contributor Author

Forgon uploaded file mxe_macros.patch (3.2 KiB)

patch file created with git format-patch (part 3/5)

@wzdev-ci
Copy link
Contributor Author

Forgon uploaded file escape_typo.patch (0.8 KiB)

patch file created with git format-patch (part 4/5)

@wzdev-ci
Copy link
Contributor Author

Forgon uploaded file assignment_parentheses.patch (1.4 KiB)

patch file created with git format-patch (part 5/5)

@wzdev-ci
Copy link
Contributor Author

Forgon uploaded file 4753_all_5_commits.patch (7.4 KiB)

all parts of this patch series joint into one patch file

@wzdev-ci
Copy link
Contributor Author

Forgon uploaded file mxe_make_error.log (762.3 KiB)

complete command line output of make with MXE before applying this patch series

@wzdev-ci
Copy link
Contributor Author

Forgon uploaded file mxe_make_success.log (714.3 KiB)

complete command line output of make with MXE after applying this patch series

@wzdev-ci
Copy link
Contributor Author

Forgon2100 <forgon2100@...> changed status from new to closed

@wzdev-ci
Copy link
Contributor Author

Forgon2100 <forgon2100@...> changed owner from `` to Forgon2100 <forgon2100@gmail.com>

@wzdev-ci
Copy link
Contributor Author

Forgon2100 <forgon2100@...> changed resolution from `` to fixed

@wzdev-ci
Copy link
Contributor Author

Forgon2100 <forgon2100@...> commented


In Warzone2100/warzone2100@be42a20:

#CommitTicketReference repository="" revision="be42a20bab36c3f9211ae1d56f75936817f55617"
fixes #4753: do not use -fPIC compiler flags for Windows (patch 1/5)

@wzdev-ci
Copy link
Contributor Author

Forgon2100 <forgon2100@...> committed [066]


In Warzone2100/warzone2100@066e900:

#CommitTicketReference repository="" revision="066e900a2761c88d634f22a5a293696d039a508b"
fixes #4753: MSVC-specific pragma no longer executed with other platforms (patch 2/5)

@wzdev-ci
Copy link
Contributor Author

Forgon2100 <forgon2100@...> committed [74364172]


In Warzone2100/warzone2100@7436417:

#CommitTicketReference repository="" revision="74364172c5f728424900d9d9f2b445c8f01341ca"
fixes #4753: added MXE-specific macros to properly print format specifiers PRIu32, PRIu64 and PRId64 (patch 3/5)

@wzdev-ci
Copy link
Contributor Author

Forgon2100 <forgon2100@...> committed [11]


In Warzone2100/warzone2100@11fcfa2:

#CommitTicketReference repository="" revision="11fcfa22945dae237fd7e5cfa3a1723357fd38a4"
fixes #4753: fixed typo: /0 -> \0 (patch 4/5)

@wzdev-ci
Copy link
Contributor Author

Forgon2100 <forgon2100@...> commented


In Warzone2100/warzone2100@ad63e40:

#CommitTicketReference repository="" revision="ad63e40595557cfca82479f7d43f2031eaf978bc"
fixes #4753: added parentheses around assignments used as truth values (patch 5/5)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant