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

ISO C++ forbids converting a string constant to ‘char*’ #332

Closed
shakaw opened this issue Mar 20, 2017 · 6 comments
Closed

ISO C++ forbids converting a string constant to ‘char*’ #332

shakaw opened this issue Mar 20, 2017 · 6 comments
Assignees

Comments

@shakaw
Copy link

shakaw commented Mar 20, 2017

/var/tmp/sqlsrv/conn.cpp:152:75: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
char* ss_sqlsrv_conn::resource_name = static_cast<char *>("ss_sqlsrv_conn");

/var/tmp/sqlsrv/init.cpp: In function ‘int zm_activate_sqlsrv(int, int)’:
/opt/remi/php71/root/usr/include/php/Zend/zend_ini.h:139:62: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
#define INI_INT(name) zend_ini_long((name), sizeof(name)-1, 0)
^
/opt/remi/php71/root/usr/include/php/Zend/zend_ini.h:142:37: note: in expansion of macro ‘INI_INT’
#define INI_BOOL(name) ((zend_bool) INI_INT(name))
^
/var/tmp/sqlsrv/init.cpp:639:45: note: in expansion of macro ‘INI_BOOL’
SQLSRV_G( warnings_return_as_errors ) = INI_BOOL( INI_PREFIX INI_WARNINGS_RETURN_AS_ERRORS);
^
/opt/remi/php71/root/usr/include/php/Zend/zend_ini.h:139:62: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
#define INI_INT(name) zend_ini_long((name), sizeof(name)-1, 0)
^
/var/tmp/sqlsrv/init.cpp:640:32: note: in expansion of macro ‘INI_INT’
SQLSRV_G( log_severity ) = INI_INT( INI_PREFIX INI_LOG_SEVERITY);
^
/opt/remi/php71/root/usr/include/php/Zend/zend_ini.h:139:62: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
#define INI_INT(name) zend_ini_long((name), sizeof(name)-1, 0)
^
/var/tmp/sqlsrv/init.cpp:641:34: note: in expansion of macro ‘INI_INT’
SQLSRV_G( log_subsystems ) = INI_INT( INI_PREFIX INI_LOG_SUBSYSTEMS);
^
/opt/remi/php71/root/usr/include/php/Zend/zend_ini.h:139:62: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
#define INI_INT(name) zend_ini_long((name), sizeof(name)-1, 0)
^

@yukiwongky
Copy link
Contributor

hi @shakaw,

We are unable to reproduce the warning. From what I see in our current source code,
char* ss_sqlsrv_conn::resource_name = static_cast<char *>("ss_sqlsrv_conn");
no longer exist, instead it is
const char* ss_sqlsrv_conn::resource_name = "ss_sqlsrv_conn";

Please try to build the driver again using the latest version of our driver and let us know if the warning exist. Also, would you mind giving us more context? Which version of our driver are you using? Which version of PHP 7.1 are you using? What platform are you building the driver on? What compiler are you using?

@shakaw
Copy link
Author

shakaw commented Mar 21, 2017

I'm sorry. It's for driver 4.0.8. New version compiling succesful, but have some warnings:

In file included from /opt/remi/php71/root/usr/include/php/main/php_ini.h:24:0,
from /opt/remi/php71/root/usr/include/php/main/fopen_wrappers.h:26,
from /opt/remi/php71/root/usr/include/php/main/php.h:407,
from /var/tmp/sqlsrv/shared/core_sqlsrv.h:34,
from /var/tmp/sqlsrv/php_sqlsrv.h:25,
from /var/tmp/sqlsrv/init.cpp:19:
/var/tmp/sqlsrv/init.cpp: In function ‘int zm_activate_sqlsrv(int, int)’:
/opt/remi/php71/root/usr/include/php/Zend/zend_ini.h:139:62: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
#define INI_INT(name) zend_ini_long((name), sizeof(name)-1, 0)
^
/opt/remi/php71/root/usr/include/php/Zend/zend_ini.h:142:37: note: in expansion of macro ‘INI_INT’
#define INI_BOOL(name) ((zend_bool) INI_INT(name))
^
/var/tmp/sqlsrv/init.cpp:639:45: note: in expansion of macro ‘INI_BOOL’
SQLSRV_G( warnings_return_as_errors ) = INI_BOOL( INI_PREFIX INI_WARNINGS_RETURN_AS_ERRORS );
^
/opt/remi/php71/root/usr/include/php/Zend/zend_ini.h:139:62: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
#define INI_INT(name) zend_ini_long((name), sizeof(name)-1, 0)
^
/var/tmp/sqlsrv/init.cpp:640:32: note: in expansion of macro ‘INI_INT’
SQLSRV_G( log_severity ) = INI_INT( INI_PREFIX INI_LOG_SEVERITY );
^
/opt/remi/php71/root/usr/include/php/Zend/zend_ini.h:139:62: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
#define INI_INT(name) zend_ini_long((name), sizeof(name)-1, 0)
^
/var/tmp/sqlsrv/init.cpp:641:34: note: in expansion of macro ‘INI_INT’
SQLSRV_G( log_subsystems ) = INI_INT( INI_PREFIX INI_LOG_SUBSYSTEMS );
^
/opt/remi/php71/root/usr/include/php/Zend/zend_ini.h:139:62: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
#define INI_INT(name) zend_ini_long((name), sizeof(name)-1, 0)
^
/var/tmp/sqlsrv/init.cpp:642:40: note: in expansion of macro ‘INI_INT’
SQLSRV_G( buffered_query_limit ) = INI_INT( INI_PREFIX INI_BUFFERED_QUERY_LIMIT );

@yukiwongky
Copy link
Contributor

What platform are you building the driver on? And what compiler are you using?

@shakaw
Copy link
Author

shakaw commented Mar 21, 2017

sh-4.1$ uname -a
Linux dvib 2.6.32-642.6.2.el6.x86_64 #1 SMP Wed Oct 26 06:52:09 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

sh-4.1$ /opt/rh/devtoolset-4/root/usr/bin/c++ -v
Using built-in specs.
COLLECT_GCC=/opt/rh/devtoolset-4/root/usr/bin/c++
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-4/root/usr/libexec/gcc/x86_64-redhat-linux/5.3.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-4/root/usr --mandir=/opt/rh/devtoolset-4/root/usr/share/man --infodir=/opt/rh/devtoolset-4/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --disable-libgcj --with-default-libstdcxx-abi=gcc4-compatible --with-isl=/builddir/build/BUILD/gcc-5.3.1-20160406/obj-x86_64-redhat-linux/isl-install --enable-libmpx --with-mpc=/builddir/build/BUILD/gcc-5.3.1-20160406/obj-x86_64-redhat-linux/mpc-install --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 5.3.1 20160406 (Red Hat 5.3.1-6) (GCC)

@yukiwongky
Copy link
Contributor

We are able to reproduce the warning. We will investigate on this and get back to you.

@yukiwongky
Copy link
Contributor

The fix should be in the latest release (4.1.8-preview). Please check to see if your problem still exist.

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

No branches or pull requests

4 participants