Skip to content

Commit a839827

Browse files
committed
CONPY-189: Windows build fix for Visual Studio 2022
- Build parameters are now written to config_win.h instead of passing them as command line parameters - Fixed several compiler warnings
1 parent aaba6e2 commit a839827

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

include/mariadb_python.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <limits.h>
3333

3434
#if defined(_WIN32)
35+
#include <config_win.h>
3536
#include <windows.h>
3637
#ifdef _MSC_VER
3738
typedef SSIZE_T ssize_t;

mariadb/mariadb_codecs.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,10 @@ static PyObject *Mrdb_GetTimeDelta(MYSQL_TIME *tm)
392392
{
393393
int days, hour, minute, second, second_part;
394394

395-
hour= (tm->neg) ? -tm->hour : tm->hour;
396-
minute= (tm->neg) ? -tm->minute : tm->minute;
397-
second= (tm->neg) ? -tm->second : tm->second;
398-
second_part= (tm->neg) ? -tm->second_part : tm->second_part;
395+
hour= (tm->neg) ? -1 * tm->hour : tm->hour;
396+
minute= (tm->neg) ? -1 * tm->minute : tm->minute;
397+
second= (tm->neg) ? -1 * tm->second : tm->second;
398+
second_part= (tm->neg) ? -1 * tm->second_part : tm->second_part;
399399

400400
days= hour / 24;
401401
hour= hour % 24;
@@ -1432,7 +1432,7 @@ int clock_gettime(int dummy, struct timespec *ct)
14321432
}
14331433

14341434
ct->tv_sec = count.QuadPart / g_counts_per_sec.QuadPart;
1435-
ct->tv_nsec = ((count.QuadPart % g_counts_per_sec.QuadPart) * 1E09) / g_counts_per_sec.QuadPart;
1435+
ct->tv_nsec = (long)(((count.QuadPart % g_counts_per_sec.QuadPart) * 1E09) / g_counts_per_sec.QuadPart);
14361436

14371437
return 0;
14381438
}

mariadb/mariadb_connection.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ MrdbConnection_Initialize(MrdbConnection *self,
312312
}
313313

314314
self->thread_id= mysql_thread_id(self->mysql);
315-
mariadb_get_infov(self->mysql, MARIADB_CONNECTION_HOST, &self->host);
315+
mariadb_get_infov(self->mysql, MARIADB_CONNECTION_HOST, (void *)&self->host);
316316

317317
has_error= 0;
318318
end:
@@ -465,7 +465,7 @@ MrdbConnection_executecommand(MrdbConnection *self,
465465
return NULL;
466466

467467
Py_BEGIN_ALLOW_THREADS;
468-
rc= mysql_send_query(self->mysql, cmd, strlen(cmd));
468+
rc= mysql_send_query(self->mysql, cmd, (long)strlen(cmd));
469469
Py_END_ALLOW_THREADS;
470470

471471
if (rc)

mariadb/mariadb_cursor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ MrdbCursor_execute_text(MrdbCursor *self, PyObject *args)
11021102
db= self->connection->mysql;
11031103

11041104
Py_BEGIN_ALLOW_THREADS;
1105-
rc= mysql_send_query(db, statement, statement_len);
1105+
rc= mysql_send_query(db, statement, (long)statement_len);
11061106
Py_END_ALLOW_THREADS;
11071107

11081108
if (rc)

mariadb_windows.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,9 @@ def get_config(options):
6161
else:
6262
print("dynamic")
6363
cfg.extra_link_args= ["/NODEFAULTLIB:LIBCMT"]
64-
cfg.extra_compile_args=["\"-DDEFAULT_PLUGINS_SUBDIR=\\\"\"" + options["install_dir"].replace(""'\\', '/') + "/lib/plugin\"\\\"\"", "/MD"]
64+
cfg.extra_compile_args=["/MD"]
65+
66+
f= open("./include/config_win.h", "w")
67+
f.write("#define DEFAULT_PLUGINS_SUBDIR \"%s\\\\lib\\\\plugin\"" % options["install_dir"].replace(""'\\', '\\\\'))
68+
f.close()
6569
return cfg

0 commit comments

Comments
 (0)