[PATCH] Fix nrnpython_getline signature

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
csh
Posts: 52
Joined: Mon Feb 06, 2006 12:45 pm
Location: University College London
Contact:

[PATCH] Fix nrnpython_getline signature

Post by csh » Sat May 17, 2014 6:44 am

With the latest 'Release 7.3' release branch, I get the following build error:

Code: Select all

libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../.. -I../../src/nrnoc -I../../src/oc -I../../src/parallel -I../../src/nrnjava -I../../src/nrncvode -I../../src/ivos -I../../src/sundials -I. -I../../src/nrniv -I../../src/ivoc -I../../src/nrnoc -I../../src/oc -I../../src/nrnmpi -I../../src/gnu -I/opt/local/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m -I/Applications/MacPorts/NEURON/iv/include -I/usr/X11/include -DOOP=1 -DCABLE=1 -DUSECVODE=1 -DUSEMATRIX=1 -DUSEBBS=1 -g -O2 -MT nrnpython.lo -MD -MP -MF .deps/nrnpython.Tpo -c nrnpython.cpp  -fno-common -DPIC -o .libs/nrnpython.o
nrnpython.cpp:169:32: error: assigning to 'char *(*)(FILE *, FILE *, const char *)' from incompatible type 'char *(FILE *, FILE *, char *)': type mismatch at 3rd parameter ('const char *' vs 'char *')
                PyOS_ReadlineFunctionPointer = nrnpython_getline;
                                             ^ ~~~~~~~~~~~~~~~~~
This is with

Code: Select all

$ gcc --version
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.2.0
Thread model: posix
$ ./configure --prefix=/Applications/MacPorts/NEURON/nrn --with-iv=/Applications/MacPorts/NEURON/iv --with-nrnpython=/opt/local/bin/python3.4
The attached patch fixes this issue.

Code: Select all

# HG changeset patch
# User Christoph Schmidt-Hieber <christsc@gmx.de>
# Date 1400324388 -3600
#      Sat May 17 11:59:48 2014 +0100
# Branch Release 7.3
# Node ID 946df8f006332ee183409c222a22a6766860153f
# Parent  ecf32eddfbc761a9a2368804e2f00fd4b8699c23
Fix nrnpython_getline signature

diff -r ecf32eddfbc7 -r 946df8f00633 src/nrnpython/nrnpython.cpp
--- a/src/nrnpython/nrnpython.cpp	Thu Mar 27 14:30:04 2014 -0400
+++ b/src/nrnpython/nrnpython.cpp	Sat May 17 11:59:48 2014 +0100
@@ -21,7 +21,7 @@
 extern char* neuronhome_forward();
 //extern char*(*PyOS_ReadlineFunctionPointer)(FILE*, FILE*, char*);
 #if ((PY_MAJOR_VERSION >= 3) || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 2))
-static char* nrnpython_getline(FILE*, FILE*, char*);
+static char* nrnpython_getline(FILE*, FILE*, const char*);
 #else
 static char* nrnpython_getline(char*);
 #endif
@@ -207,12 +207,12 @@
 }
 
 #if ((PY_MAJOR_VERSION >= 3) || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 2))
-static char* nrnpython_getline(FILE*, FILE*, char* prompt) {
+static char* nrnpython_getline(FILE*, FILE*, const char* prompt) {
 #else
 static char* nrnpython_getline(char* prompt) {
 #endif
 	hoc_cbufstr->buf[0] = '\0';
-	hoc_promptstr = prompt;
+	hoc_promptstr = (char*)prompt;
 	int r = hoc_get_line();
 //printf("r=%d c=%d\n", r, hoc_cbufstr->buf[0]);
 	if (r == 1) {
Regrettably BBCode doesn't preserve all leading spaces - let me know if you require a correctly formatted patch by email.

Post Reply