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

Building luasql-odbc on windows platform fails with GCC 14 #174

Closed
deining opened this issue Dec 15, 2024 · 2 comments
Closed

Building luasql-odbc on windows platform fails with GCC 14 #174

deining opened this issue Dec 15, 2024 · 2 comments

Comments

@deining
Copy link
Contributor

deining commented Dec 15, 2024

I'm trying to compile luasql-odbc with latest MSYS2 version as described in issue #155, but I'm running in trouble.

This is due to the fact that MSYS2 now ships with GCC version 14.2.0

$ gcc --version
gcc.exe (Rev2, Built by MSYS2 project) 14.2.0
Copyright (C) 2024 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.

As stated in Porting to GCC 14, GCC is more strict now:

The initial ISO C standard and its 1999 revision removed support for many C language features
that were widely known as sources of application bugs due to accidental misuse. For backwards
compatibility, GCC 13 and earlier diagnosed use of these features as warnings only. Although
these warnings have been enabled by default for many releases, experience shows that these
warnings are easily ignored, resulting in difficult to diagnose bugs. In GCC 14, these issues are
now reported as errors, and no output file is created, providing clearer feedback to programmers
that something is wrong.

Therefore, compilation now fails due to errors that used to be warnings in GCC 13:

luasql-odbc 2.6.0-3 depends on lua >= 5.1 (5.3-1 provided by VM)
gcc -O2 -fPIC -c -o src/luasql.o -IC:\msys64\mingw64/include/lua5.3 src/luasql.c -IC:/msys64/mingw64/include/
gcc -O2 -fPIC -c -o src/ls_odbc.o -IC:\msys64\mingw64/include/lua5.3 src/ls_odbc.c -IC:/msys64/mingw64/include/
src/ls_odbc.c: In function 'raw_execute':
src/ls_odbc.c:689:51: error: passing argument 2 of 'SQLRowCount' from incompatible pointer type [-Wincompatible-pointer-types]
  689 |                 if(error(SQLRowCount(stmt->hstmt, &numrows))) {
      |                                                   ^~~~~~~~
      |                                                   |
      |                                                   SQLINTEGER * {aka long int *}
In file included from C:/msys64/mingw64/include/sqlext.h:9,
                 from src/ls_odbc.c:16:
C:/msys64/mingw64/include/sql.h:550:66: note: expected 'SQLLEN *' {aka 'long long int *'} but argument is of type 'SQLINTEGER *' {aka 'long int *'}
  550 |   SQLRETURN SQL_API SQLRowCount(SQLHSTMT StatementHandle,SQLLEN *RowCount);
      |                                                          ~~~~~~~~^~~~~~~~
src/ls_odbc.c: In function 'set_param':
src/ls_odbc.c:707:78: error: passing argument 10 of 'SQLBindParameter' from incompatible pointer type [-Wincompatible-pointer-types]
  707 |                                                   SQL_DOUBLE, 0, 0, NULL, 0, &cbNull))) {
      |                                                                              ^~~~~~~
      |                                                                              |
      |                                                                              SQLINTEGER * {aka long int *}
+ many more errors

Any idea how to overcomes these errors? Maybe these errors are fixed already? Can I revert back to the old behaviour with GCC 14 in the meantime? Any help is appreciated!

@tomasguisasola
Copy link
Contributor

This code was updated: numrows' type is now SQLLEN, which should solve the problem. You could correct it manually or wait for the new version. We should release it soon

@Arethusag
Copy link

In case anyone else is needing this to work while pending a release, you can manually edit the odbc rockspec to use the master branch rather than the 2.6.0 release (which is 4 years old at this point).

e.g. change line 5 of luasql-odbc-2.6.0-3.rockspec to
branch = "master",

and then run luarocks install luasql-odbc-2.6.0-3.rockspec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants