未验证 提交 c2689c01 编写于 作者: S Steven G. Johnson 提交者: GitHub

avoid linker conflicts for nlopt-getopt.c + libc with getopt (#355)

* avoid linker conflicts if we use nlopt-getopt.c with a libc that has getopt

* use nlopt-getopt.h if we are missing getopt or getopt.h
上级 ff7e149c
......@@ -37,6 +37,9 @@
/* Define to 1 if you have the <getopt.h> header file. */
#cmakedefine HAVE_GETOPT_H
/* Define to 1 if you have the getopt function in your standard libary. */
#cmakedefine HAVE_GETOPT
/* Define to 1 if you have the `getpid' function. */
#cmakedefine HAVE_GETPID
......
......@@ -34,6 +34,14 @@
#ifndef NLOPT_GETOPT_H
#define NLOPT_GETOPT_H
/* avoid linker conflicts if we use nlopt-getopt.c with a libc that has getopt */
#define opterr nlopt_opterr
#define optind nlopt_optind
#define optopt nlopt_optopt
#define optreset nlopt_optreset
#define optarg nlopt_optarg
#define getopt nlopt_getopt
#ifdef __cplusplus
extern "C" {
#endif
......
......@@ -30,7 +30,7 @@
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_GETOPT_H
#if defined(HAVE_GETOPT_H) && defined(HAVE_GETOPT)
# include <getopt.h>
#else
# include "nlopt-getopt.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册