Bug #68875 Connector/C++ build fails with 'snprintf' was not declared in this scope
Submitted: 5 Apr 2013 20:10 Modified: 13 Oct 2014 9:48
Reporter: Tarun Khanna Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / C++ Severity:S3 (Non-critical)
Version:1.0.5 OS:Linux (Ubuntu 12.04)
Assigned to: CPU Architecture:Any

[5 Apr 2013 20:10] Tarun Khanna
Description:
When compiling the Connector/C++ source, the compiler returns an error.

'snprintf' was not declared in this scope or
'printf' was not declared in this scope 
 
The is because on some OS distributions stdio is not included by default. 

The source was obtained from http://dev.mysql.com/downloads/connector/cpp/1.0.html

How to repeat:
It should be easy to repeat by compiling on Ubuntu or Fedora.

Suggested fix:
Add the line '#include <cstdio> to at least the following files and any other files that use printf/snprintf or related functions.

driver/mysql_resultbind.cpp
driver/mysql_art_resultset.cpp
test/unit/classes/resultsetmetadata.cpp
test/unit/unit_fixture.cpp
[13 Apr 2013 23:55] MySQL Verification Team
Thank you for the bug report.

Scanning dependencies of target mysqlcppconn
[  1%] Building CXX object driver/CMakeFiles/mysqlcppconn.dir/mysql_art_resultset.o
/home/miguel/mysql-connector-c++-1.0.5/driver/mysql_art_resultset.cpp: In member function ‘std::string sql::mysql::MyVal::getString()’:
/home/miguel/mysql-connector-c++-1.0.5/driver/mysql_art_resultset.cpp:57:68: error: ‘snprintf’ was not declared in this scope
/home/miguel/mysql-connector-c++-1.0.5/driver/mysql_art_resultset.cpp:63:79: error: ‘snprintf’ was not declared in this scope
/home/miguel/mysql-connector-c++-1.0.5/driver/mysql_art_resultset.cpp:69:89: error: ‘snprintf’ was not declared in this scope
/home/miguel/mysql-connector-c++-1.0.5/driver/mysql_art_resultset.cpp:75:62: error: ‘snprintf’ was not declared in this scope
make[2]: *** [driver/CMakeFiles/mysqlcppconn.dir/mysql_art_resultset.o] Error 1
make[1]: *** [driver/CMakeFiles/mysqlcppconn.dir/all] Error 2
make: *** [all] Error 2
miguel@miguel-VirtualBox:~/mysql-connector-c++-1.0.5$
[13 Oct 2014 9:48] Hemant Dangi
Issue resolved in rev#691 of 1.0.6 version.