oracle / odpi

ODPI-C: Oracle Database Programming Interface for Drivers and Applications
https://oracle.github.io/odpi/
Other
264 stars 75 forks source link

Master (b9bac3eb00c30a84f75e9ca67f422600de5552c8) does not compile #136

Closed tgulacsi closed 4 years ago

tgulacsi commented 4 years ago

https://github.com/oracle/odpi/blob/b9bac3eb00c30a84f75e9ca67f422600de5552c8/src/dpiOci.c#L1799

Where is Dl_info defined?

I've tried to compile with godror, but fails:

gcc errors for preamble:
In file included from ./odpi/embed/dpi.c:37,
                 from ./drv.go:49:
./odpi/embed/../src/dpiOci.c: In function 'dpiOci__loadLibInModuleDir':
./odpi/embed/../src/dpiOci.c:1799:5: error: unknown type name 'Dl_info'
 1799 |     Dl_info info;
      |     ^~~~~~~

Then I searched for Dl_info in this repo, but it's only in dpiOci.c...

tgulacsi commented 4 years ago

With this patch, it compiles:

--- a/include/dpi.h
+++ b/include/dpi.h
@@ -40,15 +40,6 @@ extern "C" {
 #include <stdint.h>
 #endif

+#ifndef _MSC_VER
+#ifndef        _DLFCN_H
+#ifndef __USE_GNU
+#define __USE_GNU 1
+#endif
+#include <dlfcn.h>
+#endif
+#endif
+
 // define __func__ for older versions of Microsoft Visual Studio
 #ifdef _MSC_VER
 #if _MSC_VER < 1900
--- a/src/dpiError.c
+++ b/src/dpiError.c
@@ -256,8 +256,7 @@ int dpiError__setFromOS(dpiError *error, const char *action)

     char buffer[512];
     int err = errno;
+// https://linux.die.net/man/3/strerror_r
+#if !defined _GNU_SOURCE && (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
-#if defined _GNU_SOURCE && !defined __APPLE__
     message = strerror_r(err, buffer, sizeof(buffer));
 #else
     message = (strerror_r(err, buffer, sizeof(buffer)) == 0) ? buffer : NULL;
cjbj commented 4 years ago

Hi @tgulacsi FWIW here is doc on how we are exposing the new library loading functionality in node-oracledb and cx_Oracle: https://github.com/oracle/node-oracledb/blob/master/doc/api.md#odbinitoracleclient, https://github.com/oracle/node-oracledb/blob/master/doc/api.md#initnodeoracledb, https://github.com/oracle/python-cx_Oracle/blob/master/doc/src/user_guide/initialization.rst

tgulacsi commented 4 years ago

@cjbj sorry, I don't understand: those nice docs only mention installing, and not C compiling issues...

cjbj commented 4 years ago

@tgulacsi it was just an FYI if you were playing with the library loading code.

anthony-tuininga commented 4 years ago

@tgulacsi, what platform and compiler are you using? dlfcn.h is what defines the structure Dl_info and is already present -- but that may be specific to the configurations I am using. The two suggested changes do not appear to be dealing with the same matter. Can you clarify?

tgulacsi commented 4 years ago

See https://github.com/godror/godror/tree/odpi-v4 After go generate (which downloads a fresh odpi-c/master.zip and unzips under odpi), go install fails with

! gcc --version
gcc (Debian 9.3.0-13) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
! go install -x
WORK=/tmp/go-build317506907
mkdir -p $WORK/b040/
cat >$WORK/b040/importcfg << 'EOF' # internal
# import config
EOF
cd /home/tgulacsi/go/pkg/mod/golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543/internal
/usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/b040/_pkg_.a -trimpath "$WORK/b040=>" -p golang.org/x/xerrors/internal -lang=go1.11 -complete -buildid _x4dfffS-TDInVW5f_AD/_x4dfffS-TDInVW5f_AD -goversion go1.14.4 -D "" -importcfg $WORK/b040/importcfg -pack -c=4 ./internal.go
/usr/local/go/pkg/tool/linux_amd64/buildid -w $WORK/b040/_pkg_.a # internal
cp $WORK/b040/_pkg_.a /home/tgulacsi/.cache/go-build/f6/f628d87f3b42d0e4ce64c4222f05cde86fcf76a78dab6dd27b6e0cf22dda40fc-d # internal
mkdir -p $WORK/b039/
cat >$WORK/b039/importcfg << 'EOF' # internal
# import config
packagefile bytes=/usr/local/go/pkg/linux_amd64/bytes.a
packagefile fmt=/usr/local/go/pkg/linux_amd64/fmt.a
packagefile golang.org/x/xerrors/internal=$WORK/b040/_pkg_.a
packagefile io=/usr/local/go/pkg/linux_amd64/io.a
packagefile reflect=/usr/local/go/pkg/linux_amd64/reflect.a
packagefile runtime=/usr/local/go/pkg/linux_amd64/runtime.a
packagefile strconv=/usr/local/go/pkg/linux_amd64/strconv.a
packagefile strings=/usr/local/go/pkg/linux_amd64/strings.a
packagefile unicode=/usr/local/go/pkg/linux_amd64/unicode.a
packagefile unicode/utf8=/usr/local/go/pkg/linux_amd64/unicode/utf8.a
EOF
cd /home/tgulacsi/go/pkg/mod/golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543
/usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/b039/_pkg_.a -trimpath "$WORK/b039=>" -p golang.org/x/xerrors -lang=go1.11 -complete -buildid gQM8PyY5iPK8zqlzuKnK/gQM8PyY5iPK8zqlzuKnK -goversion go1.14.4 -D "" -importcfg $WORK/b039/importcfg -pack -c=4 ./adaptor.go ./doc.go ./errors.go ./fmt.go ./format.go ./frame.go ./wrap.go
/usr/local/go/pkg/tool/linux_amd64/buildid -w $WORK/b039/_pkg_.a # internal
cp $WORK/b039/_pkg_.a /home/tgulacsi/.cache/go-build/ef/ef4a6f8d6e9e13f9a205a7b91455272b6d95e928eb488bfd88b4d524c7b12d93-d # internal
mkdir -p $WORK/b001/
cd /home/tgulacsi/src/github.com/godror/godror
CGO_LDFLAGS='"-g" "-O2" "-ldl" "-lpthread"' /usr/local/go/pkg/tool/linux_amd64/cgo -objdir $WORK/b001/ -importpath github.com/godror/godror -- -I $WORK/b001/ -g -O2 -I/home/tgulacsi/src/github.com/godror/godror/odpi/include -I/home/tgulacsi/src/github.com/godror/godror/odpi/src -I/home/tgulacsi/src/github.com/godror/godror/odpi/embed ./conn.go ./data.go ./drv.go ./drv_posix.go ./lob.go ./obj.go ./queue.go ./rows.go ./stmt.go ./subscr.go
# github.com/godror/godror
In file included from ./odpi/embed/dpi.c:37,
                 from ./drv.go:50:
./odpi/embed/../src/dpiOci.c: In function 'dpiOci__loadLibInModuleDir':
./odpi/embed/../src/dpiOci.c:1799:5: error: unknown type name 'Dl_info'
 1799 |     Dl_info info;
      |     ^~~~~~~
./odpi/embed/../src/dpiOci.c:1803:56: error: request for member 'dli_fname' in something not a structure or union
 1803 |             dpiDebug__print("module name is %s\n", info.dli_fname);
      |                                                        ^
./odpi/embed/../src/dpiOci.c:1804:31: error: request for member 'dli_fname' in something not a structure or union
 1804 |         dirName = strrchr(info.dli_fname, '/');
      |                               ^
./odpi/embed/../src/dpiOci.c:1806:59: error: request for member 'dli_fname' in something not a structure or union
 1806 |             return dpiOci__loadLibWithDir(loadParams, info.dli_fname,
      |                                                           ^
./odpi/embed/../src/dpiOci.c:1807:45: error: request for member 'dli_fname' in something not a structure or union
 1807 |                     (size_t) (dirName - info.dli_fname), 0, error);
      | 

but ODPI-C v3.3.0 works flawlessly:

$ git checkout -f master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
:tgulacsi@tgulacsi-dell: ~/src/github.com/godror/godror
$ go install -x
WORK=/tmp/go-build296461973
mkdir -p $WORK/b001/
cd /home/tgulacsi/src/github.com/godror/godror
CGO_LDFLAGS='"-g" "-O2" "-ldl" "-lpthread"' /usr/local/go/pkg/tool/linux_amd64/cgo -objdir $WORK/b001/ -importpath github.com/godror/godror -- -I $WORK/b001/ -g -O2 -I/home/tgulacsi/src/github.com/godror/godror/odpi/include -I/home/tgulacsi/src/github.com/godror/godror/odpi/src -I/home/tgulacsi/src/github.com/godror/godror/odpi/embed ./conn.go ./data.go ./drv.go ./drv_posix.go ./lob.go ./obj.go ./queue.go ./rows.go ./stmt.go ./subscr.go
cd $WORK
gcc -fno-caret-diagnostics -c -x c - -o /dev/null || true
gcc -Qunused-arguments -c -x c - -o /dev/null || true
gcc -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true
gcc -gno-record-gcc-switches -c -x c - -o /dev/null || true
cd $WORK/b001
TERM='dumb' gcc -I /home/tgulacsi/src/github.com/godror/godror -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I/home/tgulacsi/src/github.com/godror/godror/odpi/include -I/home/tgulacsi/src/github.com/godror/godror/odpi/src -I/home/tgulacsi/src/github.com/godror/godror/odpi/embed -o ./_x001.o -c _cgo_export.c
TERM='dumb' gcc -I /home/tgulacsi/src/github.com/godror/godror -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I/home/tgulacsi/src/github.com/godror/godror/odpi/include -I/home/tgulacsi/src/github.com/godror/godror/odpi/src -I/home/tgulacsi/src/github.com/godror/godror/odpi/embed -o ./_x002.o -c conn.cgo2.c
TERM='dumb' gcc -I /home/tgulacsi/src/github.com/godror/godror -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I/home/tgulacsi/src/github.com/godror/godror/odpi/include -I/home/tgulacsi/src/github.com/godror/godror/odpi/src -I/home/tgulacsi/src/github.com/godror/godror/odpi/embed -o ./_x003.o -c data.cgo2.c
TERM='dumb' gcc -I /home/tgulacsi/src/github.com/godror/godror -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I/home/tgulacsi/src/github.com/godror/godror/odpi/include -I/home/tgulacsi/src/github.com/godror/godror/odpi/src -I/home/tgulacsi/src/github.com/godror/godror/odpi/embed -o ./_x004.o -c drv.cgo2.c
TERM='dumb' gcc -I /home/tgulacsi/src/github.com/godror/godror -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I/home/tgulacsi/src/github.com/godror/godror/odpi/include -I/home/tgulacsi/src/github.com/godror/godror/odpi/src -I/home/tgulacsi/src/github.com/godror/godror/odpi/embed -o ./_x005.o -c drv_posix.cgo2.c
TERM='dumb' gcc -I /home/tgulacsi/src/github.com/godror/godror -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I/home/tgulacsi/src/github.com/godror/godror/odpi/include -I/home/tgulacsi/src/github.com/godror/godror/odpi/src -I/home/tgulacsi/src/github.com/godror/godror/odpi/embed -o ./_x006.o -c lob.cgo2.c
TERM='dumb' gcc -I /home/tgulacsi/src/github.com/godror/godror -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I/home/tgulacsi/src/github.com/godror/godror/odpi/include -I/home/tgulacsi/src/github.com/godror/godror/odpi/src -I/home/tgulacsi/src/github.com/godror/godror/odpi/embed -o ./_x007.o -c obj.cgo2.c
TERM='dumb' gcc -I /home/tgulacsi/src/github.com/godror/godror -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I/home/tgulacsi/src/github.com/godror/godror/odpi/include -I/home/tgulacsi/src/github.com/godror/godror/odpi/src -I/home/tgulacsi/src/github.com/godror/godror/odpi/embed -o ./_x008.o -c queue.cgo2.c
TERM='dumb' gcc -I /home/tgulacsi/src/github.com/godror/godror -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I/home/tgulacsi/src/github.com/godror/godror/odpi/include -I/home/tgulacsi/src/github.com/godror/godror/odpi/src -I/home/tgulacsi/src/github.com/godror/godror/odpi/embed -o ./_x009.o -c rows.cgo2.c
TERM='dumb' gcc -I /home/tgulacsi/src/github.com/godror/godror -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I/home/tgulacsi/src/github.com/godror/godror/odpi/include -I/home/tgulacsi/src/github.com/godror/godror/odpi/src -I/home/tgulacsi/src/github.com/godror/godror/odpi/embed -o ./_x010.o -c stmt.cgo2.c
TERM='dumb' gcc -I /home/tgulacsi/src/github.com/godror/godror -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I/home/tgulacsi/src/github.com/godror/godror/odpi/include -I/home/tgulacsi/src/github.com/godror/godror/odpi/src -I/home/tgulacsi/src/github.com/godror/godror/odpi/embed -o ./_x011.o -c subscr.cgo2.c
cd /home/tgulacsi/src/github.com/godror/godror
TERM='dumb' gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I $WORK/b001/ -g -O2 -I/home/tgulacsi/src/github.com/godror/godror/odpi/include -I/home/tgulacsi/src/github.com/godror/godror/odpi/src -I/home/tgulacsi/src/github.com/godror/godror/odpi/embed -o $WORK/b001/_x012.o -c subscr.c
cd $WORK/b001
TERM='dumb' gcc -I /home/tgulacsi/src/github.com/godror/godror -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I/home/tgulacsi/src/github.com/godror/godror/odpi/include -I/home/tgulacsi/src/github.com/godror/godror/odpi/src -I/home/tgulacsi/src/github.com/godror/godror/odpi/embed -o ./_cgo_main.o -c _cgo_main.c
cd /home/tgulacsi/src/github.com/godror/godror
TERM='dumb' gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -o $WORK/b001/_cgo_.o $WORK/b001/_cgo_main.o $WORK/b001/_x001.o $WORK/b001/_x002.o $WORK/b001/_x003.o $WORK/b001/_x004.o $WORK/b001/_x005.o $WORK/b001/_x006.o $WORK/b001/_x007.o $WORK/b001/_x008.o $WORK/b001/_x009.o $WORK/b001/_x010.o $WORK/b001/_x011.o $WORK/b001/_x012.o -g -O2 -ldl -lpthread
TERM='dumb' /usr/local/go/pkg/tool/linux_amd64/cgo -dynpackage godror -dynimport $WORK/b001/_cgo_.o -dynout $WORK/b001/_cgo_import.go
cat >$WORK/b001/importcfg << 'EOF' # internal
# import config
packagefile bufio=/usr/local/go/pkg/linux_amd64/bufio.a
packagefile bytes=/usr/local/go/pkg/linux_amd64/bytes.a
packagefile context=/usr/local/go/pkg/linux_amd64/context.a
packagefile database/sql=/usr/local/go/pkg/linux_amd64/database/sql.a
packagefile database/sql/driver=/usr/local/go/pkg/linux_amd64/database/sql/driver.a
packagefile encoding/base64=/usr/local/go/pkg/linux_amd64/encoding/base64.a
packagefile fmt=/usr/local/go/pkg/linux_amd64/fmt.a
packagefile golang.org/x/xerrors=/home/tgulacsi/.cache/go-build/ef/ef4a6f8d6e9e13f9a205a7b91455272b6d95e928eb488bfd88b4d524c7b12d93-d
packagefile hash/fnv=/usr/local/go/pkg/linux_amd64/hash/fnv.a
packagefile io=/usr/local/go/pkg/linux_amd64/io.a
packagefile log=/usr/local/go/pkg/linux_amd64/log.a
packagefile math=/usr/local/go/pkg/linux_amd64/math.a
packagefile net/url=/usr/local/go/pkg/linux_amd64/net/url.a
packagefile reflect=/usr/local/go/pkg/linux_amd64/reflect.a
packagefile runtime=/usr/local/go/pkg/linux_amd64/runtime.a
packagefile strconv=/usr/local/go/pkg/linux_amd64/strconv.a
packagefile strings=/usr/local/go/pkg/linux_amd64/strings.a
packagefile sync=/usr/local/go/pkg/linux_amd64/sync.a
packagefile time=/usr/local/go/pkg/linux_amd64/time.a
packagefile unicode/utf8=/usr/local/go/pkg/linux_amd64/unicode/utf8.a
packagefile runtime/cgo=/usr/local/go/pkg/linux_amd64/runtime/cgo.a
packagefile syscall=/usr/local/go/pkg/linux_amd64/syscall.a
EOF
/usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/b001/_pkg_.a -trimpath "$WORK/b001=>" -p github.com/godror/godror -lang=go1.12 -buildid us3IAQH13_7xsjLYHEq0/us3IAQH13_7xsjLYHEq0 -goversion go1.14.4 -D "" -importcfg $WORK/b001/importcfg -pack -c=4 ./orahlp.go ./orahlp_go13.go ./stmt_go13.go ./version.go $WORK/b001/_cgo_gotypes.go $WORK/b001/conn.cgo1.go $WORK/b001/data.cgo1.go $WORK/b001/drv.cgo1.go $WORK/b001/drv_posix.cgo1.go $WORK/b001/lob.cgo1.go $WORK/b001/obj.cgo1.go $WORK/b001/queue.cgo1.go $WORK/b001/rows.cgo1.go $WORK/b001/stmt.cgo1.go $WORK/b001/subscr.cgo1.go $WORK/b001/_cgo_import.go
/usr/local/go/pkg/tool/linux_amd64/pack r $WORK/b001/_pkg_.a $WORK/b001/_x001.o $WORK/b001/_x002.o $WORK/b001/_x003.o $WORK/b001/_x004.o $WORK/b001/_x005.o $WORK/b001/_x006.o $WORK/b001/_x007.o $WORK/b001/_x008.o $WORK/b001/_x009.o $WORK/b001/_x010.o $WORK/b001/_x011.o $WORK/b001/_x012.o # internal
/usr/local/go/pkg/tool/linux_amd64/buildid -w $WORK/b001/_pkg_.a # internal
cp $WORK/b001/_pkg_.a /home/tgulacsi/.cache/go-build/86/861b9e8503483ee5576ad4783c907e2794658b88e5ef4cadba0bc9dd212ee70d-d # internal
kubo commented 4 years ago

@tgulacsi Could you add the following code to dpiImpl.h and check the error message?

#ifdef __GNUC__
#error __GNUC__ is defined.
#else
#error __GNUC__ isn't defined.
#endif

I guess that __GNUC__ isn't defined in cgo so _GNU_SOURCE isn't defined here. When _GNU_SOURCE is defined before #include <dlfcn.h>, Dl_info is available. See SYNOPSIS in the dladdr man page.

I think that this line should check __linux__ instead of __GNUC__. That's because gcc is available not only on Linux but also on other platforms such as Solaris. If _GNU_SOURCE is defined on Solaris, it causes trouble here.

@tgulacsi Could you check the following code also to check whether __linux__ is defined in cgo.

#ifdef __linux__
#error __linux__ is defined.
#else
#error __linux__ is not defined.
#endif
tgulacsi commented 4 years ago

On 06/16/2020 1:33 PM Kubo Takehiro notifications@github.com wrote:

@tgulacsi (https://github.com/tgulacsi) Could you add the following code to dpiImpl.h and check the error message?

ifdef GNUC

error GNUC is defined.

else

error GNUC isn't defined.

endif

I guess that GNUC isn't defined in cgo so _GNU_SOURCE isn't defined here (https://github.com/oracle/odpi/blob/b6f2b14b92e74239516edb01f2c55199e4067019/src/dpiImpl.h#L22-L26). When _GNU_SOURCE is defined before #include , Dl_info is available. See SYNOPSIS in the dladdr man page (https://www.man7.org/linux/man-pages/man3/dladdr.3.html). I think that this line (https://github.com/oracle/odpi/blob/b6f2b14b92e74239516edb01f2c55199e4067019/src/dpiImpl.h#L24) should check linux instead of GNUC. That's because gcc is available not only on Linux but also on other platforms such as Solaris. If _GNU_SOURCE is defined on Solaris, it causes trouble here (https://github.com/oracle/odpi/blob/b6f2b14b92e74239516edb01f2c55199e4067019/src/dpiError.c#L259-L263). @tgulacsi (https://github.com/tgulacsi) Could you check the following code also to check whether linux is defined in cgo.

ifdef linux

error linux is defined.

else

error linux is not defined.

endif

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub (https://github.com/oracle/odpi/issues/136#issuecomment-644706896), or unsubscribe (https://github.com/notifications/unsubscribe-auth/AAB6QSV2IML2ODZ2HBAS273RW5J7RANCNFSM4NZCPM5Q).

! go clean -cache ; go install

github.com/godror/godror

In file included from ./conn.go:10: ./odpi/src/dpiImpl.h:23:2: error: #error linux is defined. 23 | #error linux is defined. | ^~~~~ ./odpi/src/dpiImpl.h:29:2: error: #error GNUC is defined. 29 | #error GNUC is defined. | ^~~~~

tgulacsi commented 4 years ago

TL;DR; first define macros, then include libs.

This was the solution:

diff --git a/drv.go b/drv.go
index 0848d8a..7077a51 100644
--- a/drv.go
+++ b/drv.go
@@ -44,9 +44,6 @@ package godror
 /*
 #cgo CFLAGS: -I./odpi/include -I./odpi/src -I./odpi/embed

-#include <stdlib.h>
-
-
 #include "dpi.c"
 */
 import "C"

Sorry for the noise, thanks for the suggestions!

cjbj commented 4 years ago

I'm going to reopen this as a reminder until we've reviewed the ODPI macro change suggested by @kubo.

kubo commented 4 years ago
./odpi/src/dpiImpl.h:29:2: error: #error __GNUC__ is defined.
   29 | #error __GNUC__ is defined.
      |  ^~~~~

Thanks. My guess is incorrect.

TL;DR; first define macros, then include libs.

That’s correct. _GNU_SOURCE must be defined before any header file which implicitly includes /usr/include/features.h.

anthony-tuininga commented 4 years ago

I believe I have addressed the suggestion made by @kubo. Instead of __linux__ I used __GLIBC__ -- currently that is pretty much equivalent but other platforms may implement or use glibc as well, so I think that's more appropriate.

kubo commented 4 years ago

Instead of linux I used GLIBC -- currently that is pretty much equivalent but other platforms may implement or use glibc as well, so I think that's more appropriate.

Do you think that __GNUC__ is defined when the C library is glibc? It is defined by gcc (and also by clang). gcc on any platform defines __GNUC__ even when the compiler uses a C library other than glibc.

Edited: strike-through line was added.

anthony-tuininga commented 4 years ago

I'm not using __GNUC__ but __GLIBC -- which should only be defined when the C library used is glibc -- which has the different version of strerror_r(). Can you clarify your comment?

kubo commented 4 years ago

Sorry, I looked a bit old code. I missed this commit.

I found another issue about strerror_r on cygwin and mingw-w64. I'll open a new issue later.

kubo commented 4 years ago

I opened #138 to report a strerror_r issue on cygwin.

As for mingw-w64, there are no problems. I thought that ODPI-C cannot be compiled because mingw-w64 doesn't implement strerror_r. However strerror_r is not used because _WIN32 is defined by mingw compiler.