Can't completely get rid of #ifndef FRONTEND in palloc.h :-(
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 28 Apr 2014 01:24:19 +0000 (21:24 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 28 Apr 2014 01:24:30 +0000 (21:24 -0400)
pg_controldata includes postgres.h not postgres_fe.h, so utils/palloc.h
must be able to compile in a "#define FRONTEND" context.  It appears that
Solaris Studio is smart enough to persuade us to define PG_USE_INLINE,
but not smart enough to not make a copy of unreferenced static functions;
which leads to an unsatisfied reference to CurrentMemoryContext.  So we
need an #ifndef FRONTEND around that declaration.  Per buildfarm.

src/include/utils/palloc.h

index f865069d19dafd91e585c11d467d9b8ed3a84fe4..5bb217d1d2d10bb237a0b5042922bc08313998b4 100644 (file)
@@ -71,8 +71,14 @@ extern void pfree(void *pointer);
  * MemoryContextSwitchTo can't be a macro in standard C compilers.
  * But we can make it an inline function if the compiler supports it.
  * See STATIC_IF_INLINE in c.h.
+ *
+ * Although this header file is nominally backend-only, certain frontend
+ * programs like pg_controldata include it via postgres.h.  For some compilers
+ * it's necessary to hide the inline definition of MemoryContextSwitchTo in
+ * this scenario; hence the #ifndef FRONTEND.
  */
 
+#ifndef FRONTEND
 #ifndef PG_USE_INLINE
 extern MemoryContext MemoryContextSwitchTo(MemoryContext context);
 #endif   /* !PG_USE_INLINE */
@@ -86,6 +92,7 @@ MemoryContextSwitchTo(MemoryContext context)
    return old;
 }
 #endif   /* PG_USE_INLINE || MCXT_INCLUDE_DEFINITIONS */
+#endif   /* FRONTEND */
 
 /*
  * These are like standard strdup() except the copied string is