Skip to content

Name clash in pllmod_common.{c,h} when building with MinGW-W64 #28

@jdx-gh

Description

@jdx-gh

Please look at amkozlov/raxml-ng#138.

Under MinGW errno is defined in errno.h in the following way:

[...]
#ifndef _CRT_ERRNO_DEFINED
#define _CRT_ERRNO_DEFINED
_CRTIMP extern int *__cdecl _errno(void);
#define errno (*_errno())

errno_t __cdecl _set_errno(int _Value);
errno_t __cdecl _get_errno(int *_Value);
#endif /* _CRT_ERRNO_DEFINED */
[...]

Therefore, as shown in the original report, there is a name clash during compilation.

Here is the patch:

diff --git a/src/pllmod_common.c b/src/pllmod_common.c
index ff8979a..45f9e3f 100644
--- a/src/pllmod_common.c
+++ b/src/pllmod_common.c
@@ -39,9 +39,9 @@
  * @param[in] errmsg_fmt formatted error message
  */
 __attribute__((format(printf, 2, 3)))
-void pllmod_set_error(int errno, const char* errmsg_fmt, ...)
+void pllmod_set_error(int errcode, const char* errmsg_fmt, ...)
 {
-  pll_errno = errno;
+  pll_errno = errcode;
 
   va_list args;
   va_start(args, errmsg_fmt);
diff --git a/src/pllmod_common.h b/src/pllmod_common.h
index 9d51ad5..19374c2 100644
--- a/src/pllmod_common.h
+++ b/src/pllmod_common.h
@@ -40,7 +40,7 @@
 #define PLLMOD_ERROR_INVALID_INDEX                1003
 #define PLLMOD_ERROR_NOT_IMPLEMENTED              1004
 
-void pllmod_set_error(int errno, const char* errmsg_fmt, ...);
+void pllmod_set_error(int errcode, const char* errmsg_fmt, ...);
 void pllmod_reset_error();
 
 #endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions