From: Alexei Sheplyakov Date: Wed, 6 Jan 2010 17:55:43 +0000 (+0200) Subject: Use C style cast when converting void* into function pointer. X-Git-Tag: release_1-6-0~20 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=commitdiff_plain;h=c0fcba137d26486085ed5d4104b34d2c44978693;hp=c0fcba137d26486085ed5d4104b34d2c44978693;p=ginac.git Use C style cast when converting void* into function pointer. Building GiNaC 1.5.5 with GCC 3.4 fails with the following error: libtool: compile: ccache g++-3.4 -DHAVE_CONFIG_H -I. -I../../ginac -I../config -I/home/pc7135/varg/target/x86_64-linux-gnu/include -O2 -g -Wall -pipe -MT builtin_fcns.lo -MD -MP -MF .deps/builtin_fcns.Tpo -c ../../ginac/parser/builtin_fcns.cpp -fPIC -DPIC -o .libs/builtin_fcns.o ../../ginac/parser/builtin_fcns.cpp: In function `GiNaC::ex (* GiNaC::encode_serial_as_reader_func(unsigned int))(const GiNaC::exvector&)': /home/pc7135/varg/tmp/build/GiNaC/build-linux-gcc-3.4/ginac/../../ginac/parser/builtin_fcns.cpp|67| error: ISO C++ forbids casting between pointer-to-function and pointer-to-object make[2]: *** [builtin_fcns.lo] Error 1 The C++98 standard [expr.reinterpret.cast] does not allow reinterpret_cast(void*) reinterpret_cast(function_pointer) But the ability to do so is important for a lot of practical uses. So soon after the C++98 standard was approved, a language defect report was filed on this topic, see http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#195 The result is that compilers will be allowed to support reinterpret_cast conversions of function pointers to other (pointers) types, and vice a versa. Such conversions work with *current* compilers (GCC 4.x), but don't work with older ones, hence this patch. ---