[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#477010: taking the address of a macro



The attached patch against the original source tree should solve the problem.

Regards,
Chris

On Tue, May 6, 2008 at 10:43 PM, Christopher L Conway
<cconway@cs.nyu.edu> wrote:
> The problem is that the relevant lines are trying to create function
>  pointers, but the identifiers named are really macros.
>
>  The following example gives a similar error:
>
>  macroptr.c:
>  int f(int x, int y, int z) { return 0; }
>  #define FOO(x) f(x,0,0)
>
>  int (*p)() = &f;
>  int (*q)() = &FOO;
>
>  $ gcc macroptr.c
>  macroptr.c:5: error: 'FOO' undeclared here (not in a function)
>
>  It's strange this hasn't been a problem before, because the
>  declarations have been macros for several years in the Python trunk.
>
>
>
>  --
>  To unsubscribe, send mail to 477010-unsubscribe@bugs.debian.org.
>
>
diff -ruN -x cvs -x CVS -x '*~' -x config.log /home/chris/downloads/pycaml/Makefile.in pycaml/Makefile.in
--- /home/chris/downloads/pycaml/Makefile.in	2003-09-17 01:30:15.000000000 -0400
+++ pycaml/Makefile.in	2008-05-06 21:49:38.000000000 -0400
@@ -5,6 +5,8 @@
 PY_PREFIX=@PY_PREFIX@
 PY_VERSION=@PY_VERSION@
 SYSLIBS=@PY_LIBS@
+OCAMLC=ocamlc
+OCAMLMKTOP=ocamlmktop
 
 #
 # The rest is automatic
@@ -18,23 +20,23 @@
 all: pycamltop pycamltest ocamlobj
 
 pycamltop: pycaml_ml.o pycaml.cmo
-	ocamlmktop -thread -custom -o $@ $(LIBS)
+	$(OCAMLMKTOP) -thread -custom -o $@ $(LIBS)
 
 pycaml_ml.o: pycaml_ml.c
-	ocamlc -thread -ccopt -c -ccopt -g \
+	$(OCAMLC) -thread -ccopt -c -ccopt -g \
 	-ccopt -I$(PY_PREFIX)/include/python$(PY_VERSION) $<
 
 pycaml.cmo: pycaml.ml
-	ocamlc -thread -c $<
+	$(OCAMLC) -thread -c $<
 
 pycamltest: pycamltest.ml pycaml.cmo pycaml_ml.o
-	ocamlc -custom -thread -ccopt -g $(LIBS) pycamltest.ml -o $@
+	$(OCAMLC) -custom -thread -ccopt -g $(LIBS) pycamltest.ml -o $@
 
 ocamlobj: ocamlobj.ml pycaml.cmo pycaml_ml.o
-	ocamlc -custom -thread -ccopt -g $(LIBS) ocamlobj.ml -o $@
+	$(OCAMLC) -custom -thread -ccopt -g $(LIBS) ocamlobj.ml -o $@
 
 clean:
 	rm -rf *.o *.cmi *.cmo pycamltop pycamltest ocamlobj
 
 distclean: clean
-	rm -rf config.cache autom4te.cache config.status Makefile
\ No newline at end of file
+	rm -rf config.cache autom4te.cache config.status Makefile
diff -ruN -x cvs -x CVS -x '*~' -x config.log /home/chris/downloads/pycaml/pycaml_ml.c pycaml/pycaml_ml.c
--- /home/chris/downloads/pycaml/pycaml_ml.c	2004-12-02 11:17:07.000000000 -0500
+++ pycaml/pycaml_ml.c	2008-05-07 10:40:21.000000000 -0400
@@ -897,6 +897,27 @@
     CAMLreturn(*v);
 }
 
+int wrap_PyRun_SimpleString(const char *s) { return PyRun_SimpleString(s); }
+int wrap_PyRun_AnyFile(FILE *f, const char * p) { return PyRun_AnyFile(f,p); }
+int wrap_PyRun_AnyFileEx(FILE *f, const char * p, int c) { return PyRun_AnyFileEx(f,p,c); }
+int wrap_PyRun_SimpleFile(FILE *f, const char * p) { return PyRun_SimpleFile(f,p); }
+int wrap_PyRun_SimpleFileEx(FILE *f, const char * p, int c) { return PyRun_SimpleFileEx(f,p,c); }
+int wrap_PyRun_InteractiveOne(FILE *f, const char * p) { return PyRun_InteractiveOne(f,p); }
+int wrap_PyRun_InteractiveLoop(FILE *f, const char * p) { return PyRun_InteractiveLoop(f,p); }
+PyObject * wrap_PyRun_String(const char *str, int s, PyObject * g, PyObject * l) {
+  return PyRun_String(str,s,g,l); 
+}
+PyObject * wrap_PyRun_File(FILE *f, const char *p, int s, PyObject * g, PyObject * l) {
+  return PyRun_File(f,p,s,g,l); 
+}
+PyObject *wrap_PyRun_FileEx(FILE *f, const char *p, int s, PyObject * g, PyObject * l,int c) {
+  return PyRun_FileEx(f,p,s,g,l,c); 
+}
+PyObject * wrap_Py_CompileString(const char *str, const char *p, int s) {
+  return Py_CompileString(str,p,s); 
+}
+
+
 /* Create the function table */
 
 typedef struct _python_func_table {
@@ -919,16 +940,16 @@
 /* 4 */
     { (void *)Py_IsInitialized, 4, "Py_IsInitialized" },
 /* 5 */
-    { (void *)PyRun_SimpleString, 5, "PyRun_SimpleString" },
+    { (void *)wrap_PyRun_SimpleString, 5, "PyRun_SimpleString" },
 /* 6 */
-    { (void *)PyRun_AnyFile, 6, "PyRun_AnyFile" },
-    { (void *)PyRun_SimpleFile, 6, "PyRun_SimpleFile" },
-    { (void *)PyRun_InteractiveOne, 6, "PyRun_InteractiveOne" },
-    { (void *)PyRun_InteractiveLoop, 6, "PyRun_InteractiveLoop" },
+    { (void *)wrap_PyRun_AnyFile, 6, "PyRun_AnyFile" },
+    { (void *)wrap_PyRun_SimpleFile, 6, "PyRun_SimpleFile" },
+    { (void *)wrap_PyRun_InteractiveOne, 6, "PyRun_InteractiveOne" },
+    { (void *)wrap_PyRun_InteractiveLoop, 6, "PyRun_InteractiveLoop" },
     { (void *)Py_FdIsInteractive, 6, "Py_FdIsInteractive" },
 /* 7 */
-    { (void *)PyRun_AnyFileEx, 7, "PyRun_AnyFileEx" },
-    { (void *)PyRun_SimpleFileEx, 7, "PyRun_SimpleFileEx" },
+    { (void *)wrap_PyRun_AnyFileEx, 7, "PyRun_AnyFileEx" },
+    { (void *)wrap_PyRun_SimpleFileEx, 7, "PyRun_SimpleFileEx" },
 /* 8 */
     { (void *)Py_GetProgramName, 8, "Py_GetProgramName" },
     { (void *)Py_GetPythonHome, 8, "Py_GetPythonHome" },
@@ -942,13 +963,13 @@
     { (void *)Py_GetCompiler, 8, "Py_GetCompiler" },
     { (void *)Py_GetBuildInfo, 8, "Py_GetBuildInfo" },
 /* 9 */
-    { (void *)PyRun_String, 9, "PyRun_String" },
+    { (void *)wrap_PyRun_String, 9, "PyRun_String" },
 /* 10 */
-    { (void *)PyRun_File, 10, "PyRun_File" },
+    { (void *)wrap_PyRun_File, 10, "PyRun_File" },
 /* 11 */
-    { (void *)PyRun_FileEx, 11, "PyRun_FileEx" },
+    { (void *)wrap_PyRun_FileEx, 11, "PyRun_FileEx" },
 /* 12 */
-    { (void *)Py_CompileString, 12, "Py_CompileString" },
+    { (void *)wrap_Py_CompileString, 12, "Py_CompileString" },
 
 /* Object */
 /* 13 */
@@ -1062,8 +1083,9 @@
     { (void *)PySlice_New, 42, "PySlice_New" },
 /* 43 */
     { (void *)PySlice_GetIndices, 43, "PySlice_GetIndices" },
-/* 44 */
-    { (void *)PyRange_New, 44, "PyRange_New" },
+/* 44 */ 
+    /* PyRange_New has been removed from the API */
+    /* { (void *)PyRange_New, 44, "PyRange_New" }, */
 
 /* Error handling definitions */
 

Reply to: