comparison src/if_python3.c @ 13561:417a01a1aaaa v8.0.1654

patch 8.0.1654: warnings for conversion of void to function pointer commit https://github.com/vim/vim/commit/7b24ce08fe99345cac035215fca29c7e174a6456 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 29 18:15:26 2018 +0200 patch 8.0.1654: warnings for conversion of void to function pointer Problem: Warnings for conversion of void to function pointer. Solution: Use a temp variable that is a function pointer.
author Christian Brabandt <cb@256bit.org>
date Thu, 29 Mar 2018 18:30:07 +0200
parents eafe575966ff
children 1feeefd8cddb
comparison
equal deleted inserted replaced
13560:197a3a32eff0 13561:417a01a1aaaa
598 */ 598 */
599 static int 599 static int
600 py3_runtime_link_init(char *libname, int verbose) 600 py3_runtime_link_init(char *libname, int verbose)
601 { 601 {
602 int i; 602 int i;
603 void *ucs_from_string, *ucs_decode, *ucs_as_encoded_string; 603 PYTHON_PROC *ucs_from_string = (PYTHON_PROC *)&py3_PyUnicode_FromString;
604 PYTHON_PROC *ucs_decode = (PYTHON_PROC *)&py3_PyUnicode_Decode;
605 PYTHON_PROC *ucs_as_encoded_string =
606 (PYTHON_PROC *)&py3_PyUnicode_AsEncodedString;
604 607
605 # if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON) 608 # if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON)
606 /* Can't have Python and Python3 loaded at the same time. 609 /* Can't have Python and Python3 loaded at the same time.
607 * It cause a crash, because RTLD_GLOBAL is needed for 610 * It cause a crash, because RTLD_GLOBAL is needed for
608 * standard C extension libraries of one or both python versions. */ 611 * standard C extension libraries of one or both python versions. */
639 } 642 }
640 643
641 /* Load unicode functions separately as only the ucs2 or the ucs4 functions 644 /* Load unicode functions separately as only the ucs2 or the ucs4 functions
642 * will be present in the library. */ 645 * will be present in the library. */
643 # if PY_VERSION_HEX >= 0x030300f0 646 # if PY_VERSION_HEX >= 0x030300f0
644 ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicode_FromString"); 647 *ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicode_FromString");
645 ucs_decode = symbol_from_dll(hinstPy3, "PyUnicode_Decode"); 648 *ucs_decode = symbol_from_dll(hinstPy3, "PyUnicode_Decode");
646 ucs_as_encoded_string = symbol_from_dll(hinstPy3, 649 *ucs_as_encoded_string = symbol_from_dll(hinstPy3,
647 "PyUnicode_AsEncodedString"); 650 "PyUnicode_AsEncodedString");
648 # else 651 # else
649 ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicodeUCS2_FromString"); 652 *ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicodeUCS2_FromString");
650 ucs_decode = symbol_from_dll(hinstPy3, 653 *ucs_decode = symbol_from_dll(hinstPy3,
651 "PyUnicodeUCS2_Decode"); 654 "PyUnicodeUCS2_Decode");
652 ucs_as_encoded_string = symbol_from_dll(hinstPy3, 655 *ucs_as_encoded_string = symbol_from_dll(hinstPy3,
653 "PyUnicodeUCS2_AsEncodedString"); 656 "PyUnicodeUCS2_AsEncodedString");
654 if (!ucs_from_string || !ucs_decode || !ucs_as_encoded_string) 657 if (*ucs_from_string == NULL || *ucs_decode == NULL
655 { 658 || *ucs_as_encoded_string == NULL)
656 ucs_from_string = symbol_from_dll(hinstPy3, 659 {
660 *ucs_from_string = symbol_from_dll(hinstPy3,
657 "PyUnicodeUCS4_FromString"); 661 "PyUnicodeUCS4_FromString");
658 ucs_decode = symbol_from_dll(hinstPy3, 662 *ucs_decode = symbol_from_dll(hinstPy3,
659 "PyUnicodeUCS4_Decode"); 663 "PyUnicodeUCS4_Decode");
660 ucs_as_encoded_string = symbol_from_dll(hinstPy3, 664 *ucs_as_encoded_string = symbol_from_dll(hinstPy3,
661 "PyUnicodeUCS4_AsEncodedString"); 665 "PyUnicodeUCS4_AsEncodedString");
662 } 666 }
663 # endif 667 # endif
664 if (ucs_from_string && ucs_decode && ucs_as_encoded_string) 668 if (*ucs_from_string == NULL || *ucs_decode == NULL
665 { 669 || *ucs_as_encoded_string == NULL)
666 py3_PyUnicode_FromString = ucs_from_string;
667 py3_PyUnicode_Decode = ucs_decode;
668 py3_PyUnicode_AsEncodedString = ucs_as_encoded_string;
669 }
670 else
671 { 670 {
672 close_dll(hinstPy3); 671 close_dll(hinstPy3);
673 hinstPy3 = 0; 672 hinstPy3 = 0;
674 if (verbose) 673 if (verbose)
675 EMSG2(_(e_loadfunc), "PyUnicode_UCSX_*"); 674 EMSG2(_(e_loadfunc), "PyUnicode_UCSX_*");