Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nim string definition conflicts with other C/C++ instances #10907

Closed
genotrance opened this issue Mar 26, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@genotrance
Copy link
Contributor

commented Mar 26, 2019

The Oracle Instant Client code has the following definition in oratypes.h.

typedef  oratext *string;

This conflicts with nimbase.h:

typedef struct TStringDesc* string;

Ideally the Nim implementation should use a unique name so that it doesn't conflict with any existing C/C++ libs that are wrapped.

import oci

let username = "...".cstring
let password = "...".cstring
let server   = "...".cstring

let ptrUsername = cast[ptr OraText](username)
let ptrPassword = cast[ptr OraText](password)
let ptrServer   = cast[ptr OraText](server)

var
  xtramemsz = 0.cuint
  nimOCIEnv = 0.cuint
  nimOCIError: ptr OCIError
  PNimOCIEnv: ptr OCIEnv
  PPNimOCIEnv = PNimOCIEnv.addr
  addrXtramemsz: ptr = xtramemsz.addr
  usrmempp: pointer
  Pusrmempp = usrmempp.addr
  nimOCI_DEFAULT = cast[ub4](OCI_DEFAULT)


# proc OCIEnvInit*(envp: ptr ptr OCIEnv; mode: ub4; xtramem_sz: cuint; usrmempp: ptr pointer): sword {.importc, header: headerociap.}
var environment = OCIEnvInit(PPNimOCIEnv, nimOCI_DEFAULT, xtramemsz, Pusrmempp)

# ERROR:
# ======
# In file included from C:/code/instantclient_18_5/sdk/include/ociap.h:802:0,
#                  from C:\Users\jaredfields\nimcache\nim_Oracle_r\nim_Oracle.c:10:
# C:/code/instantclient_18_5/sdk/include/oratypes.h:311:19: error: conflicting types for 'string'
#  typedef  oratext *string;
#                    ^~~~~~
# In file included from C:\Users\jaredfields\nimcache\nim_Oracle_r\nim_Oracle.c:9:0:
# C:\nim\lib/nimbase.h:397:29: note: previous declaration of 'string' was here
#  typedef struct TStringDesc* string;
#                              ^~~~~~

genotrance added a commit to genotrance/Nim that referenced this issue Mar 26, 2019

narimiran added a commit that referenced this issue May 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.