[CDRIVER-2] platform_hacks.h functions require a cast from void * to char * in C++ compilers Created: 03/Dec/09  Updated: 19/Oct/16  Resolved: 03/Dec/09

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 0.2

Type: Bug Priority: Major - P3
Reporter: Orlando Vazquez Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

ubuntu server 32bit



 Description   

Compiling the drivers causes a compiler error on c++ compilers (or at least, g++):

In file included from /home/orlando/projects/node-mongodb/mongo-c-driver/src/bson.h:6,
from ../bson.cc:4:
/home/orlando/projects/node-mongodb/mongo-c-driver/src/platform_hacks.h:24:2: error: #error must have a 64bit int type
In file included from /home/orlando/projects/node-mongodb/mongo-c-driver/src/bson.h:6,
from ../bson.cc:4:
/home/orlando/projects/node-mongodb/mongo-c-driver/src/platform_hacks.h: In function 'void bson_swap_endian64(void*, const void*)':
/home/orlando/projects/node-mongodb/mongo-c-driver/src/platform_hacks.h:50: error: invalid conversion from 'const void*' to 'const char*'
/home/orlando/projects/node-mongodb/mongo-c-driver/src/platform_hacks.h:51: error: invalid conversion from 'void*' to 'char*'
/home/orlando/projects/node-mongodb/mongo-c-driver/src/platform_hacks.h: In function 'void bson_swap_endian32(void*, const void*)':
/home/orlando/projects/node-mongodb/mongo-c-driver/src/platform_hacks.h:64: error: invalid conversion from 'const void*' to 'const char*'
/home/orlando/projects/node-mongodb/mongo-c-driver/src/platform_hacks.h:65: error: invalid conversion from 'void*' to 'char*'

Explicitly casting the arguments of these functions to (char *) seems to make it work.



 Comments   
Comment by auto [ 03/Dec/09 ]

Author:

{'name': 'Mathias Stearn', 'email': 'redbeard0531@gmail.com'}

Message: changes to compile with C++ code. CDRIVER-2
http://github.com/mongodb/mongo-c-driver/commit/fe9cba1f43fe8803cafc71ae3309d7a613f9ffe4

Generated at Wed Feb 07 21:08:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.