687791 "Problems with VC6 makefiles (NDEBUG, /MTd)".

"Russell Lang" <[email protected]> Fri, 03 Dec 2004 21:40:46 +1100
Newsgroups gmane.comp.printing.ghostscript.patches
Message-ID <41B0DD5E.20830.4D958E78@localhost>
Raph or Ray,

http://bugs.ghostscript.com/show_bug.cgi?id=687791

Replace use of the assert macro with the GS_ASSERT macro that 
calls assert in debug code, but not in release code.
Partial fix for bug #687791 "Problems with VC6 makefiles (NDEBUG, 
/MTd)".

DETAILS:
The use of assert (even in release code) is acceptable in cases 
where the assertion failure is clearly a logic error in the code, 
rather than an exception case from, say, invalid input date. 
An assert is especially useful when catching the assertion early 
prevents a crash or more mysterious error condition later.

The system assert macro is troublesome in release code.
On some systems (e.g. when GS is running from a Windows service) 
it can result in an invisible dialog box which blocks the program.

Ghostscript code should use the GS_ASSERT macro rather than
the system assert macro.
In debug code, GS_ASSERT uses the system assert macro.
In release code, GS_ASSERT writes a message to stderr and continues.
Note that GS_ASSERT does generate code in release builds,
and will slow down execution.

Russell Lang                   [email protected]
Ghostgum Software Pty Ltd      http://www.ghostgum.com.au/

_______________________________________________
gs-code-review mailing list
[email protected]
http://www.ghostscript.com/mailman/listinfo/gs-code-review
assert2.txt (application/octet-stream, 1.9 KB)
diff -u l:/cvs/gs/doc/C-style.htm doc/C-style.htm
--- l:/cvs/gs/doc/C-style.htm	Sun Nov 21 20:02:02 2004
+++ doc/C-style.htm	Fri Dec 03 09:56:53 2004
@@ -72,6 +72,7 @@
 <li><a href="#Structure_type_descriptors">Structure type descriptors</a>
 <li><a href="#Objects">"Objects"</a>
 <li><a href="#Error_handling">Error handling</a>
+<li><a href="#Assert">Assert</a>
 </ul>
 </ul></blockquote>
 
@@ -1596,6 +1597,25 @@
 return codes used by the graphics library, most of which correspond directly
 to PostScript error conditions.
 
+<h3><a name="Assert"></a>Assert</h3>
+<p>
+The use of <b><tt>assert</tt></b> (even in release code) is 
+acceptable in cases where the assertion failure is clearly a 
+logic error in the code, rather than an exception case from, 
+say, invalid input date.
+An assert is especially useful when catching the assertion early
+prevents a crash or more mysterious error condition later.
+<p>
+Ghostscript code should use the <b><tt>GS_ASSERT</tt></b> macro 
+rather than the system assert macro.
+In debug code, <b><tt>GS_ASSERT</tt></b> uses the system assert macro.
+In release code, <b><tt>GS_ASSERT</tt></b> writes a message to stderr 
+and continues.  
+This can be changed by editing <a href="../src/assert_.h">assert_.h</a>.
+Note that <b><tt>GS_ASSERT</tt></b> does generate code 
+in release builds, and will slow down execution.
+
+
 <!-- [2.0 end contents] ==================================================== -->
 
 <!-- [3.0 begin visible trailer] =========================================== -->
Common subdirectories: l:/cvs/gs/doc/CVS and doc/CVS
diff -u l:/cvs/gs/doc/Develop.htm doc/Develop.htm
--- l:/cvs/gs/doc/Develop.htm	Sun Nov 21 20:02:04 2004
+++ doc/Develop.htm	Fri Dec 03 09:58:28 2004
@@ -4117,6 +4117,7 @@
 <dt>
 Files:
 <dd>
+<a href="../src/assert_.h">src/assert_.h</a>,
 <a href="../src/ctype_.h">src/ctype_.h</a>,
 <a href="../src/dirent_.h">src/dirent_.h</a>,
 <a href="../src/dos_.h">src/dos_.h</a>,
assert1.txt (application/octet-stream, 28.2 KB)
Only in src: assert_.h
diff -u l:/cvs/gs/src/fapi_ft.c src/fapi_ft.c
--- l:/cvs/gs/src/fapi_ft.c	Tue Nov 11 08:15:00 2003
+++ src/fapi_ft.c	Fri Dec 03 09:15:06 2004
@@ -36,7 +36,7 @@
 #include "freetype/ftoutln.h"
 #include "freetype/fttrigon.h"
 
-#include <assert.h>
+#include "assert_.h"
 
 /* Note: structure definitions here start with FF_, which stands for 'FAPI FreeType". */
 
@@ -199,7 +199,7 @@
 				*a_metrics = a_info->m_glyph_metrics;
 				break;
 			default:
-				assert(false); /* This can't happen. */
+				GS_ASSERT(false); /* This can't happen. */
 				break;
 			}
 		}
@@ -514,7 +514,7 @@
 					open_args.memory_size = FF_serialize_type1_font(a_font,own_font_data,length);
 				else
 					open_args.memory_size = FF_serialize_type2_font(a_font,own_font_data,length);
-				assert(open_args.memory_size == length);
+				GS_ASSERT(open_args.memory_size == length);
 				ft_inc_int = new_inc_int(a_font);
 				if (!ft_inc_int)
 					{
@@ -724,7 +724,7 @@
 static FAPI_retcode get_char_raster(FAPI_server *a_server,FAPI_raster *a_raster)
 	{
 	FF_server* s = (FF_server*)a_server;
-	assert(s->m_bitmap_glyph);
+	GS_ASSERT(s->m_bitmap_glyph);
 	a_raster->p = s->m_bitmap_glyph->bitmap.buffer;
 	a_raster->width = s->m_bitmap_glyph->bitmap.width;
 	a_raster->height = s->m_bitmap_glyph->bitmap.rows;
@@ -885,7 +885,7 @@
 static void gs_freetype_destroy(i_plugin_instance *a_plugin_instance,i_plugin_client_memory *a_memory)
 	{
 	FF_server *server = (FF_server *)a_plugin_instance;
-	assert(server->m_fapi_server.ig.d == &TheFreeTypeDescriptor);
+	GS_ASSERT(server->m_fapi_server.ig.d == &TheFreeTypeDescriptor);
 	FT_Done_Glyph(&server->m_outline_glyph->root);
 	FT_Done_Glyph(&server->m_bitmap_glyph->root);
 	FT_Done_FreeType(server->m_freetype_library);
diff -u l:/cvs/gs/src/gdevddrw.c src/gdevddrw.c
--- l:/cvs/gs/src/gdevddrw.c	Fri Aug 06 22:01:54 2004
+++ src/gdevddrw.c	Fri Dec 03 09:15:06 2004
@@ -16,7 +16,6 @@
 
 /* $Id: gdevddrw.c,v 1.25 2004/08/05 17:02:36 stefan Exp $ */
 /* Default polygon and image drawing device procedures */
-#include <assert.h>
 #include "math_.h"
 #include "memory_.h"
 #include "stdint_.h"
@@ -32,6 +31,7 @@
 #include "gxistate.h"
 #include "gdevddrw.h"
 #include "vdtrace.h"
+#include "assert_.h"
 /*
 #include "gxdtfill.h" - Do not remove this comment.
                         "gxdtfill.h" is included below.
@@ -183,7 +183,7 @@
 	    g->den = fa->yend - fa->ystart;
 	else {
 	    g->den = e->end.y - e->start.y;
-	    assert(g->den == l->h);
+	    GS_ASSERT(g->den == l->h);
 	}
 	for (i = 0; i < num_components; i++) {
 	    g->num[i] = e->c1[i] - e->c0[i];
diff -u l:/cvs/gs/src/gdevpdfc.c src/gdevpdfc.c
--- l:/cvs/gs/src/gdevpdfc.c	Wed Oct 27 08:22:33 2004
+++ src/gdevpdfc.c	Fri Dec 03 09:15:06 2004
@@ -35,7 +35,7 @@
 #include "sstring.h"
 #include "gxcspace.h"
 #include "sarc4.h"
-#include <assert.h>
+#include "assert_.h"
 
 /*
  * PDF doesn't have general CIEBased color spaces.  However, it provides
@@ -887,7 +887,7 @@
 		*ppranges = copy_ranges;
 	} else
 	    ppcs->ranges = 0;
-	assert(pca->id == pres->object->id);
+	GS_ASSERT(pca->id == pres->object->id);
 	COS_FREE(pres->object, "pdf_color_space");
 	pres->object = (cos_object_t *)pca;
 	cos_write_object(COS_OBJECT(pca), pdev);
diff -u l:/cvs/gs/src/gdevpsf1.c src/gdevpsf1.c
--- l:/cvs/gs/src/gdevpsf1.c	Fri Nov 19 06:23:03 2004
+++ src/gdevpsf1.c	Fri Dec 03 09:15:06 2004
@@ -17,8 +17,8 @@
 /* $Id: gdevpsf1.c,v 1.18 2004/11/19 04:39:11 ray Exp $ */
 /* Write an embedded Type 1 font */
 #include "memory_.h"
-#include <assert.h>
 #include "gx.h"
+#include "assert_.h"
 #include "gserrors.h"
 #include "gsccode.h"
 #include "gsmatrix.h"
@@ -304,7 +304,7 @@
 		int code;
 
 		code = pfont->procs.glyph_name((gs_font *)pfont, glyph, &gstr);
-		assert(code >= 0);
+		GS_ASSERT(code >= 0);
 		stream_puts(s, "/");
 		stream_write(s, gstr.data, gstr.size);
 		pprintd1(s, " %d -| ", gdata.bits.size);
diff -u l:/cvs/gs/src/gdevpsft.c src/gdevpsft.c
--- l:/cvs/gs/src/gdevpsft.c	Thu Nov 18 06:42:01 2004
+++ src/gdevpsft.c	Fri Dec 03 09:15:06 2004
@@ -17,9 +17,9 @@
 /* $Id: gdevpsft.c,v 1.33 2004/11/15 01:12:06 ray Exp $ */
 /* Write an embedded TrueType font */
 #include "memory_.h"
-#include <assert.h>
 #include <stdlib.h>		/* for qsort */
 #include "gx.h"
+#include "assert_.h"
 #include "gscencs.h"
 #include "gserrors.h"
 #include "gsmatrix.h"
@@ -173,7 +173,7 @@
     if (glyph == gs_no_glyph)
 	return 0;		/* .notdef */
     code = font->procs.glyph_name(font, glyph, pstr);
-    assert(code >= 0);
+    GS_ASSERT(code >= 0);
     if (glyph < gs_min_cid_glyph) {
 	gs_char mac_char;
 	gs_glyph mac_glyph;
@@ -190,7 +190,7 @@
 	if (mac_glyph == gs_no_glyph)
 	    return -1;
 	code = gs_c_glyph_name(mac_glyph, &mstr);
-	assert(code >= 0);
+	GS_ASSERT(code >= 0);
 	if (!bytes_compare(pstr->data, pstr->size, mstr.data, mstr.size))
 	    return (int)mac_char;
     }
diff -u l:/cvs/gs/src/gsfcmap.c src/gsfcmap.c
--- l:/cvs/gs/src/gsfcmap.c	Wed Oct 27 08:22:34 2004
+++ src/gsfcmap.c	Fri Dec 03 09:15:06 2004
@@ -16,10 +16,10 @@
 
 /* $Id: gsfcmap.c,v 1.25 2004/10/08 22:55:16 igor Exp $ */
 /* CMap character decoding */
-#include <assert.h>
 #include "memory_.h"
 #include "string_.h"
 #include "gx.h"
+#include "assert_.h"
 #include "gserrors.h"
 #include "gsstruct.h"
 #include "gsutil.h"		/* for gs_next_ids */
@@ -444,7 +444,7 @@
 		     uint *pindex, uint *pfidx,
 		     gs_char *pchr, gs_glyph *pglyph)
 {
-    assert(0); /* Unsupported, because never used. */
+    GS_ASSERT(0); /* Unsupported, because never used. */
     return 0;
 }
 
diff -u l:/cvs/gs/src/gsfunc0.c src/gsfunc0.c
--- l:/cvs/gs/src/gsfunc0.c	Fri Jun 18 07:30:47 2004
+++ src/gsfunc0.c	Fri Dec 03 09:15:06 2004
@@ -38,7 +38,7 @@
 				   Remove after the beta testing. */
 
 #if POLE_CACHE_DEBUG
-#   include <assert.h>
+#   include "assert_.h"
 #endif
 
 typedef struct gs_function_Sd_s {
@@ -770,9 +770,9 @@
 	    int k, code1;
 
 	    code1 = fn_Sd_evaluate_general(pfn_common, in, y);
-	    assert(code == code1);
+	    GS_ASSERT(code == code1);
 	    for (k = 0; k < pfn->params.n; k++)
-		assert(any_abs(y[k] - out[k]) <= 1e-6 * (pfn->params.Range[k * 2 + 1] - pfn->params.Range[k * 2 + 0]));
+		GS_ASSERT(any_abs(y[k] - out[k]) <= 1e-6 * (pfn->params.Range[k * 2 + 1] - pfn->params.Range[k * 2 + 0]));
 	}
 #	endif
     } else
diff -u l:/cvs/gs/src/gxccman.c src/gxccman.c
--- l:/cvs/gs/src/gxccman.c	Thu Aug 19 20:33:34 2004
+++ src/gxccman.c	Fri Dec 03 09:15:06 2004
@@ -35,7 +35,7 @@
 #include "gxxfont.h"
 #include "gxttfb.h"
 #include "gxfont42.h"
-#include <assert.h>
+#include "assert_.h"
 
 /* Define the descriptors for the cache structures. */
 private_st_cached_fm_pair();
@@ -564,7 +564,7 @@
 	       Glyph raster params could change then. */
 	    cc->pair = pair;
 	} else
-	    assert(cc->pair == pair);
+	    GS_ASSERT(cc->pair == pair);
 	cc->linked = true;
 	cc_set_pair(cc, pair);
 	pair->num_chars++;
diff -u l:/cvs/gs/src/gxcht.c src/gxcht.c
--- l:/cvs/gs/src/gxcht.c	Fri Aug 06 22:02:07 2004
+++ src/gxcht.c	Fri Dec 03 09:15:06 2004
@@ -16,9 +16,9 @@
 
 /*$Id: gxcht.c,v 1.13 2004/08/04 19:36:12 stefan Exp $ */
 /* Color halftone rendering for Ghostscript imaging library */
-#include <assert.h>
 #include "memory_.h"
 #include "gx.h"
+#include "assert_.h"
 #include "gserrors.h"
 #include "gsutil.h"		/* for id generation */
 #include "gxarith.h"
@@ -202,7 +202,7 @@
     byte *                          pdata0 = pdata;
 
     /* sanity check */
-    assert(pdevc->colors.colored.num_components == num_comps);
+    GS_ASSERT(pdevc->colors.colored.num_components == num_comps);
 
     /* check if saved color is of the same type */
     if (psdc != 0 && psdc->type != pdevc->type)
diff -u l:/cvs/gs/src/gxdhtserial.c src/gxdhtserial.c
--- l:/cvs/gs/src/gxdhtserial.c	Fri Aug 06 22:02:07 2004
+++ src/gxdhtserial.c	Fri Dec 03 09:15:06 2004
@@ -18,8 +18,8 @@
 /* Serialization and de-serialization for (traditional) halftones */
 
 #include "memory_.h"
-#include <assert.h>
 #include "gx.h"
+#include "assert_.h"
 #include "gscdefs.h"
 #include "gserrors.h"
 #include "gsstruct.h"
@@ -480,7 +480,7 @@
      *
      * NB: the pdht->order field is ignored by this code.
      */
-    assert(pdht != 0 && pdht->components != 0);
+    GS_ASSERT(pdht != 0 && pdht->components != 0);
 
     /*
      * The following fields do not need to be transmitted:
@@ -507,7 +507,7 @@
      * transmitted only once per page, so it is not clear that use of
      * such information would significantly reduce command list size.
      */
-    assert(pdht->num_comp == num_comps);
+    GS_ASSERT(pdht->num_comp == num_comps);
 
     /* calculate the required data space */
     for ( i = 0, code = gs_error_rangecheck;
@@ -516,7 +516,7 @@
         uint     tmp_size = 0;
 
         /* sanity check */
-        assert(i == pdht->components[i].comp_number);
+        GS_ASSERT(i == pdht->components[i].comp_number);
 
         code = gx_ht_write_component( &pdht->components[i],
                                       data,
diff -u l:/cvs/gs/src/gxfdrop.c src/gxfdrop.c
--- l:/cvs/gs/src/gxfdrop.c	Thu Mar 25 12:00:03 2004
+++ src/gxfdrop.c	Fri Dec 03 09:15:06 2004
@@ -17,8 +17,8 @@
 /* $Id: gxfdrop.c,v 1.14 2004/03/07 00:02:22 igor Exp $ */
 /* Dropout prevention for a character rasterization. */
 
-#include <assert.h>
 #include "gx.h"
+#include "assert_.h"
 #include "gserrors.h"
 #include "gsstruct.h"
 #include "gzpath.h"
@@ -57,7 +57,7 @@
 private margin * alloc_margin(line_list * ll)
 {   margin *m;
 
-    assert(ll->fo->pseudo_rasterization);
+    GS_ASSERT(ll->fo->pseudo_rasterization);
     if (ll->free_margin_list != 0) {
 	m = ll->free_margin_list;
 	ll->free_margin_list = ll->free_margin_list->next;
@@ -106,13 +106,13 @@
     int i0 = ii0, i1 = ii1;
     margin *m0 = set->margin_touched, *m1;
 
-    assert(ii0 >= 0 && ii1 <= ll->bbox_width);
+    GS_ASSERT(ii0 >= 0 && ii1 <= ll->bbox_width);
     set->margin_touched = 0; /* safety */
     /* Find contacting elements. */
     if (m0 != 0) {
 	margin  *m_last = m0, *mb, *me;
 
-	assert(set->margin_list != 0);
+	GS_ASSERT(set->margin_list != 0);
 	if (i1 < m0->ibeg) {
 	    do {
 		m0 = m0->prev;
@@ -248,7 +248,7 @@
 	    xp0 += fixed_1;
 	    i0++;
 	}
-	assert(i0 >= 0);
+	GS_ASSERT(i0 >= 0);
 	for (i = i0, xp = xp0; xp < xmax && i < ll->bbox_width; xp += fixed_1, i++) {
 	    fixed y = (alp == 0 ? yy0 : Y_AT_X(alp, xp));
 	    fixed dy = y - set->y;
@@ -292,7 +292,7 @@
 	    if (*b == -1 || (*b != -2 && ( ud ? *b > h : *b < h)))
 		*b = h;
 	}
-	assert(i0 >= 0 && i <= ll->bbox_width);
+	GS_ASSERT(i0 >= 0 && i <= ll->bbox_width);
 #	endif
     if (i > i0)
 	return store_margin(ll, set, i0, i);
@@ -353,7 +353,7 @@
     ii0 = i0 - ll->bbox_left;
     ii1 = fixed2int_var_pixround(x1) - ll->bbox_left;
     if (ii0 < ii1) {
-	assert(ii0 >= 0 && ii1 <= ll->bbox_width);
+	GS_ASSERT(ii0 >= 0 && ii1 <= ll->bbox_width);
 	for (i = ii0; i < ii1; i++) {
 	    sect[i].y0 = sect[i].y1 = -2;
 	    vd_circle(int2fixed(i + ll->bbox_left) + fixed_half, y, 3, RGB(255, 0, 0));
@@ -486,7 +486,7 @@
     const fill_options * const fo = ll->fo;
     const bool FILL_DIRECT = fo->fill_direct;
 
-    assert(i0 >= 0 && i1 <= ll->bbox_width);
+    GS_ASSERT(i0 >= 0 && i1 <= ll->bbox_width);
     ir = i0;
     for (i = i0; i < i1; i++) {
 	int y0 = sect[i].y0, y1 = sect[i].y1, hh;
diff -u l:/cvs/gs/src/gxpflat.c src/gxpflat.c
--- l:/cvs/gs/src/gxpflat.c	Tue Sep 28 10:03:37 2004
+++ src/gxpflat.c	Fri Dec 03 09:15:06 2004
@@ -23,7 +23,7 @@
 #include "gzpath.h"
 #include "memory_.h"
 #include "vdtrace.h"
-#include <assert.h>
+#include "assert_.h"
 
 /* ---------------- Curve flattening ---------------- */
 
@@ -422,7 +422,7 @@
 {
     bool last; /* i.e. the first one in the forth order. */
 
-    assert(this->i < 1 << this->k);
+    GS_ASSERT(this->i < 1 << this->k);
     this->lx1 = this->lx0;
     this->ly1 = this->ly0;
     if (this->k <= 1) {
@@ -452,7 +452,7 @@
     this->ly0 = this->y;
     vd_bar(this->lx0, this->ly0, this->lx1, this->ly1, 1, RGB(0, 0, 255));
     if (last)
-	assert(this->lx0 == this->x0 && this->ly0 == this->y0);
+	GS_ASSERT(this->lx0 == this->x0 && this->ly0 == this->y0);
     return !last;
 }
 
diff -u l:/cvs/gs/src/gxshade1.c src/gxshade1.c
--- l:/cvs/gs/src/gxshade1.c	Tue Sep 14 03:47:30 2004
+++ src/gxshade1.c	Fri Dec 03 09:15:06 2004
@@ -33,7 +33,7 @@
 #include "gxshade4.h"
 #include "gxdevcli.h"
 #include "vdtrace.h"
-#include <assert.h>
+#include "assert_.h"
 
 #define VD_TRACE_AXIAL_PATCH 1
 #define VD_TRACE_RADIAL_PATCH 1
@@ -1025,7 +1025,7 @@
 	    (x1 - x0) * s - (r1 - r0) * s == bbox_x - x0 + r0
 	    s = (bbox_x - x0 + r0) / (x1 - x0 - r1 + r0)
 	 */
-	assert(x1 - x0 + r1 - r0); /* We checked for obtuse cone. */
+	GS_ASSERT(x1 - x0 + r1 - r0); /* We checked for obtuse cone. */
 	sp = (rect->p.x - x0 + r0) / (x1 - x0 - r1 + r0);
 	sq = (rect->q.x - x0 + r0) / (x1 - x0 - r1 + r0);
     } else {
@@ -1136,7 +1136,7 @@
 	double da = hypot(ax - x0, ay - y0);
 	double h = r * r0 / da, g;
 
-	assert(h <= r);
+	GS_ASSERT(h <= r);
 	g = sqrt(r * r - h * h);
 	p0.x = ax - dx * g / d - dy * h / d;
 	p0.y = ay - dy * g / d + dx * h / d;
diff -u l:/cvs/gs/src/gxshade6.c src/gxshade6.c
--- l:/cvs/gs/src/gxshade6.c	Mon Sep 20 09:45:44 2004
+++ src/gxshade6.c	Fri Dec 03 09:15:06 2004
@@ -32,7 +32,7 @@
 #include "stdint_.h"
 #include "math_.h"
 #include "vdtrace.h"
-#include <assert.h>
+#include "assert_.h"
 
 #define VD_TRACE_TENSOR_PATCH 1
 
@@ -901,7 +901,7 @@
 {
     wedge_vertex_list_elem_t *e = beg->next;
 
-    assert(beg->next->next == end);
+    GS_ASSERT(beg->next->next == end);
     beg->next = end;
     end->prev = beg;
     wedge_vertex_list_elem_release(pfs, e);
@@ -930,13 +930,13 @@
 	wedge_vertex_list_t *l = ll + i;
 
 	if (l->beg != NULL) {
-	    assert(l->end != NULL);
+	    GS_ASSERT(l->end != NULL);
 	    release_wedge_vertex_list_interval(pfs, l->beg, l->end);
 	    wedge_vertex_list_elem_release(pfs, l->beg);
 	    wedge_vertex_list_elem_release(pfs, l->end);
 	    l->beg = l->end = NULL;
 	} else
-	    assert(l->end == NULL);
+	    GS_ASSERT(l->end == NULL);
     }
 }
 
@@ -946,7 +946,7 @@
 {
     wedge_vertex_list_elem_t *e = beg;
     
-    assert(beg != NULL && end != NULL);
+    GS_ASSERT(beg != NULL && end != NULL);
     for (; e != end; e = e->next)
 	if (e->level == level)
 	    return e;
@@ -1163,8 +1163,8 @@
 	    pry = q[i0].y + (fixed)iy;
 	    pey = (iy * det < num ? 1 : 0);
 #	    if USE_DOUBLE && USE_INT64_T
-		assert(*ry == pry);
-		assert(*ey == pey);
+		GS_ASSERT(*ry == pry);
+		GS_ASSERT(*ey == pey);
 #	    endif
 	    *ry = pry;
 	    *ey = pey;
@@ -1703,11 +1703,11 @@
 create_wedge_vertex_list(patch_fill_state_t *pfs, wedge_vertex_list_t *l, 
 	const gs_fixed_point *p0, const gs_fixed_point *p1)
 {
-    assert(l->end == NULL);
+    GS_ASSERT(l->end == NULL);
     l->beg = wedge_vertex_list_elem_reserve(pfs);
     l->end = wedge_vertex_list_elem_reserve(pfs);
-    assert(l->beg != NULL);
-    assert(l->end != NULL);
+    GS_ASSERT(l->beg != NULL);
+    GS_ASSERT(l->end != NULL);
     l->beg->prev = l->end->next = NULL;
     l->beg->next = l->end;
     l->end->prev = l->beg;
@@ -1723,9 +1723,9 @@
 
     /* We have got enough free elements due to the preliminary decomposition 
        of curves to LAZY_WEDGES_MAX_LEVEL, see curve_samples. */
-    assert(e != NULL); 
-    assert(l->beg->next == l->end);
-    assert(l->end->prev == l->beg);
+    GS_ASSERT(e != NULL); 
+    GS_ASSERT(l->beg->next == l->end);
+    GS_ASSERT(l->end->prev == l->beg);
     e->next = l->end;
     e->prev = l->beg;
     e->p = *p;
@@ -1735,10 +1735,10 @@
     {	int sx = l->beg->p.x < l->end->p.x ? 1 : -1;
 	int sy = l->beg->p.y < l->end->p.y ? 1 : -1;
 
-	assert((p->x - l->beg->p.x) * sx >= 0);
-	assert((p->y - l->beg->p.y) * sy >= 0);
-	assert((l->end->p.x - p->x) * sx >= 0);
-	assert((l->end->p.y - p->y) * sy >= 0);
+	GS_ASSERT((p->x - l->beg->p.x) * sx >= 0);
+	GS_ASSERT((p->y - l->beg->p.y) * sy >= 0);
+	GS_ASSERT((l->end->p.x - p->x) * sx >= 0);
+	GS_ASSERT((l->end->p.y - p->y) * sy >= 0);
     }
     return e;
 }
@@ -1752,10 +1752,10 @@
     if (!l->last_side) {
 	if (l->beg == NULL)
 	    create_wedge_vertex_list(pfs, l, p0, p1);
-	assert(l->beg->p.x == p0->x);
-	assert(l->beg->p.y == p0->y);
-	assert(l->end->p.x == p1->x);
-	assert(l->end->p.y == p1->y);
+	GS_ASSERT(l->beg->p.x == p0->x);
+	GS_ASSERT(l->beg->p.y == p0->y);
+	GS_ASSERT(l->end->p.x == p1->x);
+	GS_ASSERT(l->end->p.y == p1->y);
 	e = insert_wedge_vertex_list_elem(pfs, l, pm);
 	e->divide_count++;
 	return e;
@@ -1766,10 +1766,10 @@
 	    e->divide_count++;
 	    return e;
 	}
-	assert(l->beg->p.x == p1->x);
-	assert(l->beg->p.y == p1->y);
-	assert(l->end->p.x == p0->x);
-	assert(l->end->p.y == p0->y);
+	GS_ASSERT(l->beg->p.x == p1->x);
+	GS_ASSERT(l->beg->p.y == p1->y);
+	GS_ASSERT(l->end->p.x == p0->x);
+	GS_ASSERT(l->end->p.y == p0->y);
 	if (l->beg->next == l->end) {
 	    e = insert_wedge_vertex_list_elem(pfs, l, pm);
 	    e->divide_count++;
@@ -1777,8 +1777,8 @@
 	} else {
 	    e = wedge_vertex_list_find(l->beg, l->end, 
 			max(l->beg->level, l->end->level) + 1);
-	    assert(e != NULL);
-	    assert(e->p.x == pm->x && e->p.y == pm->y);
+	    GS_ASSERT(e != NULL);
+	    GS_ASSERT(e->p.x == pm->x && e->p.y == pm->y);
     	    e->divide_count++;
 	    return e;
 	}
@@ -2004,7 +2004,7 @@
     if (beg->next == end)
 	return 0;
     else if (beg->next->next == end) {
-	assert(beg->next->divide_count == 1 || beg->next->divide_count == 2);
+	GS_ASSERT(beg->next->divide_count == 1 || beg->next->divide_count == 2);
 	if (beg->next->divide_count != 1)
 	    return 0;
 	return fill_triangle_wedge_from_list(pfs, beg, end, beg->next, c0, c1);
@@ -2017,8 +2017,8 @@
 	p.x = (beg->p.x + end->p.x) / 2;
 	p.y = (beg->p.y + end->p.y) / 2;
 	e = wedge_vertex_list_find(beg, end, level + 1);
-	assert(e != NULL);
-	assert(e->p.x == p.x && e->p.y == p.y);
+	GS_ASSERT(e != NULL);
+	GS_ASSERT(e->p.x == p.x && e->p.y == p.y);
 	patch_interpolate_color(&c, c0, c1, pfs, 0.5);
 	code = fill_wedge_from_list_rec(pfs, beg, e, level + 1, c0, &c);
 	if (code < 0)
@@ -2026,7 +2026,7 @@
 	code = fill_wedge_from_list_rec(pfs, e, end, level + 1, &c, c1);
 	if (code < 0)
 	    return code;
-	assert(e->divide_count == 1 || e->divide_count == 2);
+	GS_ASSERT(e->divide_count == 1 || e->divide_count == 2);
 	if (e->divide_count != 1)
 	    return 0;
 	return fill_triangle_wedge_from_list(pfs, beg, end, e, c0, c1);
diff -u l:/cvs/gs/src/gzspotan.c src/gzspotan.c
--- l:/cvs/gs/src/gzspotan.c	Fri Jan 09 20:23:13 2004
+++ src/gzspotan.c	Fri Dec 03 09:15:06 2004
@@ -27,7 +27,7 @@
 #include "memory_.h"
 #include "math_.h"
 #include "vdtrace.h"
-#include <assert.h>
+#include "assert_.h"
 
 #define VD_TRAP_N_COLOR RGB(128, 128, 0)
 #define VD_TRAP_U_COLOR RGB(0, 0, 255)
@@ -126,7 +126,7 @@
 trap_unreserve(gx_device_spot_analyzer *padev, gx_san_trap *t)
 {
     /* Assuming the last reserved one. */
-    assert(t->link == padev->trap_free);
+    GS_ASSERT(t->link == padev->trap_free);
     padev->trap_free = t;
 }
 
@@ -134,7 +134,7 @@
 cont_unreserve(gx_device_spot_analyzer *padev, gx_san_trap_contact *t)
 {
     /* Assuming the last reserved one. */
-    assert(t->link == padev->cont_free);
+    GS_ASSERT(t->link == padev->cont_free);
     padev->cont_free = t;
 }
 
@@ -314,7 +314,7 @@
 	const gx_san_trap *t = list;
 
 	while (t->next != list) {
-	    assert(t->xrtop <= t->next->xltop);
+	    GS_ASSERT(t->xrtop <= t->next->xltop);
 	    t = t->next;
 	}
     }
diff -u l:/cvs/gs/src/int.mak src/int.mak
--- l:/cvs/gs/src/int.mak	Thu Nov 18 06:42:02 2004
+++ src/int.mak	Fri Dec 03 09:15:06 2004
@@ -1420,7 +1420,7 @@
 	$(ADDMOD) $(PSD)psf0read -include $(PSD)cmapread
 
 $(PSOBJ)zcfont.$(OBJ) : $(PSSRC)zcfont.c $(OP)\
- $(gsmatrix_h)\
+ $(assert__h) $(gsmatrix_h)\
  $(gxfixed_h) $(gxfont_h) $(gxtext_h)\
  $(ichar_h) $(estack_h) $(ifont_h) $(igstate_h) $(store_h)
 	$(PSCC) $(PSO_)zcfont.$(OBJ) $(C_) $(PSSRC)zcfont.c
@@ -1908,7 +1908,7 @@
 	$(ADDMOD) $(PSD)fapif1 -link $(FT_LIB)$(FT_LIB_EXT)
 
 $(PSOBJ)fapi_ft.$(OBJ) : $(PSSRC)fapi_ft.c $(AK)\
- $(stdio__h) $(math__h) $(ifapi_h)\
+ $(assert__h) $(stdio__h) $(math__h) $(ifapi_h)\
  $(FT_ROOT)$(D)include$(D)freetype$(D)freetype.h\
  $(FT_ROOT)$(D)include$(D)freetype$(D)ftincrem.h\
  $(FT_ROOT)$(D)include$(D)freetype$(D)ftglyph.h\
diff -u l:/cvs/gs/src/lib.mak src/lib.mak
--- l:/cvs/gs/src/lib.mak	Thu Nov 04 20:12:50 2004
+++ src/lib.mak	Fri Dec 03 09:15:06 2004
@@ -80,6 +80,7 @@
 
 vmsmath_h=$(GLSRC)vmsmath.h
 
+assert__h=$(GLSRC)assert_.h
 dos__h=$(GLSRC)dos_.h
 ctype__h=$(GLSRC)ctype_.h $(std_h)
 dirent__h=$(GLSRC)dirent_.h $(std_h) $(gconfig__h)
@@ -544,10 +545,11 @@
  $(gxxfont_h) $(gscspace_h) $(gximage_h) $(gxhttile_h)
 	$(GLCC) $(GLO_)gxccache.$(OBJ) $(C_) $(GLSRC)gxccache.c
 
-$(GLOBJ)gxccman.$(OBJ) : $(GLSRC)gxccman.c $(GXERR) $(memory__h) $(gpcheck_h)\
- $(gsbitops_h) $(gsstruct_h) $(gsutil_h) $(gxfixed_h) $(gxmatrix_h)\
- $(gxdevice_h) $(gxdevmem_h) $(gxfont_h) $(gxfcache_h) $(gxchar_h)\
- $(gxpath_h) $(gxxfont_h) $(gzstate_h) $(gxttfb_h) $(gxttfb_h) $(gxfont42_h)
+$(GLOBJ)gxccman.$(OBJ) : $(GLSRC)gxccman.c $(GXERR) $(assert__h) $(memory__h)\
+ $(gpcheck_h) $(gsbitops_h) $(gsstruct_h) $(gsutil_h) $(gxfixed_h)\
+ $(gxmatrix_h) $(gxdevice_h) $(gxdevmem_h) $(gxfont_h) $(gxfcache_h)\
+ $(gxchar_h) $(gxpath_h) $(gxxfont_h) $(gzstate_h) $(gxttfb_h) $(gxttfb_h)\
+ $(gxfont42_h)
 	$(GLCC) $(GLO_)gxccman.$(OBJ) $(C_) $(GLSRC)gxccman.c
 
 $(GLOBJ)gxchar.$(OBJ) : $(GLSRC)gxchar.c $(GXERR) $(memory__h) $(string__h)\
@@ -560,7 +562,7 @@
  $(gxchrout_h) $(gxfarith_h) $(gxistate_h)
 	$(GLCC) $(GLO_)gxchrout.$(OBJ) $(C_) $(GLSRC)gxchrout.c
 
-$(GLOBJ)gxcht.$(OBJ) : $(GLSRC)gxcht.c $(GXERR) $(memory__h)\
+$(GLOBJ)gxcht.$(OBJ) : $(GLSRC)gxcht.c $(GXERR) $(assert__h) $(memory__h)\
  $(gsutil_h)\
  $(gxarith_h) $(gxcmap_h) $(gxdcolor_h) $(gxdevice_h) $(gxfixed_h)\
  $(gxistate_h) $(gxmatrix_h) $(gzht_h) $(gsserial_h)
@@ -604,7 +606,7 @@
  $(gxfilltr_h) $(gxfillsl_h) $(gxfillts_h)
 	$(GLCC) $(GLO_)gxfill.$(OBJ) $(C_) $(GLSRC)gxfill.c
 
-$(GLOBJ)gxfdrop.$(OBJ) : $(GLSRC)gxfdrop.c $(GXERR)\
+$(GLOBJ)gxfdrop.$(OBJ) : $(GLSRC)gxfdrop.c $(GXERR) $(assert__h)\
  $(gsstruct_h) $(gzpath_h) $(gxfixed_h) $(gxdevice_h) $(gxdcolor_h) $(gxfill_h) $(gxfdrop_h)
 	$(GLCC) $(GLO_)gxfdrop.$(OBJ) $(C_) $(GLSRC)gxfdrop.c
 
@@ -691,7 +693,7 @@
  $(gxfixed_h) $(gzline_h) $(gzpath_h)
 	$(GLCC) $(GLO_)gxpdash.$(OBJ) $(C_) $(GLSRC)gxpdash.c
 
-$(GLOBJ)gxpflat.$(OBJ) : $(GLSRC)gxpflat.c $(GX)\
+$(GLOBJ)gxpflat.$(OBJ) : $(GLSRC)gxpflat.c $(GX) $(assert__h)\
  $(gxarith_h) $(gxfixed_h) $(gzpath_h) $(memory__h) $(string__h)\
  $(vdtrace_h)
 	$(GLCC) $(GLO_)gxpflat.$(OBJ) $(C_) $(GLSRC)gxpflat.c
@@ -1029,7 +1031,7 @@
  $(gxcpath_h) $(gxdcolor_h) $(gxdevice_h) $(gxdevmem_h)
 	$(GLCC) $(GLO_)gdevdbit.$(OBJ) $(C_) $(GLSRC)gdevdbit.c
 
-$(GLOBJ)gdevddrw.$(OBJ) : $(GLSRC)gdevddrw.c $(GXERR) $(math__h) $(memory__h) $(stdint__h)\
+$(GLOBJ)gdevddrw.$(OBJ) : $(GLSRC)gdevddrw.c $(GXERR) $(assert__h) $(math__h) $(memory__h) $(stdint__h)\
  $(gpcheck_h)\
  $(gsrect_h)\
  $(gxdcolor_h) $(gxdevice_h) $(gxfixed_h) $(gxiparam_h) $(gxistate_h) $(gxmatrix_h)\
@@ -1628,7 +1630,8 @@
 	$(GLCC) $(GLO_)gxclpath.$(OBJ) $(C_) $(GLSRC)gxclpath.c
 
 $(GLOBJ)gxdhtserial.$(OBJ) : $(GLSRC)gxdhtserial.c $(memory__h) $(GXERR)\
- $(gscdefs_h) $(gsstruct_h) $(gsutil_h) $(gzstate_h) $(gxdevice_h) $(gzht_h)\
+ $(assert__h) $(gscdefs_h) $(gsstruct_h) $(gsutil_h) $(gzstate_h)\
+ $(gxdevice_h) $(gzht_h)\
  $(gswts_h) $(gxdhtres_h) $(gsserial_h) $(gxdhtserial_h)
 	$(GLCC) $(GLO_)gxdhtserial.$(OBJ) $(C_) $(GLSRC)gxdhtserial.c
 
@@ -1704,7 +1707,7 @@
 	$(GLCC) $(GLO_)siinterp.$(OBJ) $(C_) $(GLSRC)siinterp.c
 
 $(GLOBJ)siscale.$(OBJ) : $(GLSRC)siscale.c $(AK)\
- $(math__h) $(memory__h) $(stdio__h)\
+ $(assert__h) $(math__h) $(memory__h) $(stdio__h)\
  $(gconfigv_h) $(gdebug_h)\
  $(siscale_h) $(strimpl_h)
 	$(GLCC) $(GLO_)siscale.$(OBJ) $(C_) $(GLSRC)siscale.c
@@ -1882,7 +1885,7 @@
 $(GLOBJ)gzspotan.$(OBJ) : $(GLSRC)gzspotan.c $(GXERR)\
  $(gx_h) $(gserrors_h) $(gsdevice_h) $(gzspotan_h)\
  $(gsfixed_h) $(gxdevice_h) $(gxfdrop_h) $(gzpath_h)\
- $(memory__h) $(math__h) $(vdtrace_h)
+ $(memory__h) $(math__h) $(vdtrace_h) $(assert__h)
 	$(GLCC) $(GLO_)gzspotan.$(OBJ) $(C_) $(GLSRC)gzspotan.c
 
 
@@ -1913,8 +1916,8 @@
 	$(SETMOD) $(GLD)cmaplib $(cmaplib_)
 	$(ADDMOD) $(GLD)cmaplib -include $(GLD)cidlib
 
-$(GLOBJ)gsfcmap.$(OBJ) : $(GLSRC)gsfcmap.c $(GXERR) $(memory__h) $(string__h)\
- $(gsstruct_h) $(gsutil_h) $(gxfcmap_h)
+$(GLOBJ)gsfcmap.$(OBJ) : $(GLSRC)gsfcmap.c $(GXERR) $(assert__h) $(memory__h)\
+ $(string__h) $(gsstruct_h) $(gsutil_h) $(gxfcmap_h)
 	$(GLCC) $(GLO_)gsfcmap.$(OBJ) $(C_) $(GLSRC)gsfcmap.c
 
 $(GLOBJ)gsfcmap1.$(OBJ) : $(GLSRC)gsfcmap1.c $(GXERR)\
@@ -2070,7 +2073,7 @@
 	$(ADDMOD) $(DD)psf -obj $(psf_2)
 	$(ADDMOD) $(DD)psf -obj $(psf_3)
 
-$(GLOBJ)gdevpsf1.$(OBJ) : $(GLSRC)gdevpsf1.c $(GXERR) $(memory__h)\
+$(GLOBJ)gdevpsf1.$(OBJ) : $(GLSRC)gdevpsf1.c $(GXERR) $(assert__h) $(memory__h)\
  $(gsccode_h) $(gsmatrix_h)\
  $(gxfixed_h) $(gxfont_h) $(gxfont1_h) $(gxmatrix_h) $(gxtype1_h)\
  $(sfilter_h) $(sstring_h) $(stream_h) $(strimpl_h)\
@@ -2091,7 +2094,7 @@
  $(spprint_h) $(spsdf_h) $(stream_h) $(memory__h)
 	$(GLCC) $(GLO_)gdevpsfm.$(OBJ) $(C_) $(GLSRC)gdevpsfm.c
 
-$(GLOBJ)gdevpsft.$(OBJ) : $(GLSRC)gdevpsft.c $(GXERR) $(memory__h)\
+$(GLOBJ)gdevpsft.$(OBJ) : $(GLSRC)gdevpsft.c $(GXERR) $(assert__h) $(memory__h)\
  $(gscencs_h) $(gsmatrix_h) $(gsutil_h)\
  $(gxfcid_h) $(gxfont_h) $(gxfont42_h) $(gxttf_h)\
  $(spprint_h) $(stream_h)\
@@ -2264,7 +2267,7 @@
  $(gserrors_h) $(gsparam_h) $(gxfunc_h) $(stream_h)
 	$(GLCC) $(GLO_)gsfunc.$(OBJ) $(C_) $(GLSRC)gsfunc.c
 
-$(GLOBJ)gsfunc0.$(OBJ) : $(GLSRC)gsfunc0.c $(GX) $(math__h)\
+$(GLOBJ)gsfunc0.$(OBJ) : $(GLSRC)gsfunc0.c $(GX) $(assert__h) $(math__h)\
  $(gserrors_h) $(gsfunc0_h) $(gsparam_h) $(gxfarith_h) $(gxfunc_h)
 	$(GLCC) $(GLO_)gsfunc0.$(OBJ) $(C_) $(GLSRC)gsfunc0.c
 
@@ -2523,8 +2526,8 @@
  $(gsicc_h)
 	$(GLCC) $(GLO_)gxshade.$(OBJ) $(C_) $(GLSRC)gxshade.c
 
-$(GLOBJ)gxshade1.$(OBJ) : $(GLSRC)gxshade1.c $(GXERR) $(math__h) $(memory__h)\
- $(gscoord_h) $(gsmatrix_h) $(gspath_h)\
+$(GLOBJ)gxshade1.$(OBJ) : $(GLSRC)gxshade1.c $(GXERR) $(assert__h) $(math__h)\
+ $(memory__h) $(gscoord_h) $(gsmatrix_h) $(gspath_h)\
  $(gxcspace_h) $(gxdcolor_h) $(gxfarith_h) $(gxfixed_h) $(gxistate_h)\
  $(gxpath_h) $(gxshade_h) $(gxshade4_h) $(gxdevcli_h)
 	$(GLCC) $(GLO_)gxshade1.$(OBJ) $(C_) $(GLSRC)gxshade1.c
@@ -2536,7 +2539,7 @@
  $(gxshade_h) $(gxshade4_h) $(vdtrace_h)
 	$(GLCC) $(GLO_)gxshade4.$(OBJ) $(C_) $(GLSRC)gxshade4.c
 
-$(GLOBJ)gxshade6.$(OBJ) : $(GLSRC)gxshade6.c $(GXERR) $(memory__h)\
+$(GLOBJ)gxshade6.$(OBJ) : $(GLSRC)gxshade6.c $(GXERR) $(assert__h) $(memory__h)\
  $(gscoord_h) $(gsmatrix_h)\
  $(gxcspace_h) $(gxdcolor_h) $(gxistate_h) $(gxshade_h) $(gxshade4_h) $(gxdevcli_h)\
  $(gxarith_h) $(gzpath_h) $(math__h) $(vdtrace_h)
diff -u l:/cvs/gs/src/siinterp.c src/siinterp.c
--- l:/cvs/gs/src/siinterp.c	Sun Jun 16 20:42:05 2002
+++ src/siinterp.c	Fri Dec 03 09:15:06 2004
@@ -17,7 +17,6 @@
 /* $Id: siinterp.c,v 1.5 2002/06/16 03:58:14 lpd Exp $ */
 /* Image interpolation filter */
 #include "memory_.h"
-#include <assert.h>
 #include "gxfixed.h"		/* for gxdda.h */
 #include "gxdda.h"
 #include "gxfrac.h"
diff -u l:/cvs/gs/src/siscale.c src/siscale.c
--- l:/cvs/gs/src/siscale.c	Sun Jun 16 20:42:05 2002
+++ src/siscale.c	Fri Dec 03 09:15:07 2004
@@ -19,11 +19,11 @@
 #include "math_.h"
 #include "memory_.h"
 #include "stdio_.h"
-#include <assert.h>
 #include "gconfigv.h"
 #include "gdebug.h"
 #include "strimpl.h"
 #include "siscale.h"
+#include "assert_.h"
 
 /*
  *    Image scaling code is based on public domain code from
@@ -571,7 +571,7 @@
 	if (rleft == 0)
 	    return 0;		/* need more input */
 #ifdef DEBUG
-	assert(ss->src_y < ss->params.HeightIn);
+	GS_ASSERT(ss->src_y < ss->params.HeightIn);
 #endif
 	if (rleft >= rcount) {	/* We're going to fill up a row. */
 	    const byte *row;
diff -u l:/cvs/gs/src/zcfont.c src/zcfont.c
--- l:/cvs/gs/src/zcfont.c	Sun Jun 16 20:42:05 2002
+++ src/zcfont.c	Fri Dec 03 09:15:07 2004
@@ -27,6 +27,7 @@
 #include "ifont.h"
 #include "igstate.h"
 #include "store.h"
+#include "assert_.h"
 
 /* Forward references */
 private int cshow_continue(i_ctx_t *);
@@ -103,7 +104,7 @@
 	     from the immediate parent of current font. 
 	     (The font matrix of root font is not good for the purpose
 	     in some case.) 
-	     assert (penum->fstack.items[fdepth].font == font
+	     GS_ASSERT (penum->fstack.items[fdepth].font == font
 	             && penum->fstack.items[0].font == root_font); */
 	  uint save_space = idmemory->current_space;
 	  gs_font * immediate_parent = penum->fstack.items[fdepth - 1].font;
assert_.h (application/octet-stream, 1.9 KB)
/* Copyright (C) 2004 artofcode LLC. All rights reserved.
  
  This software is provided AS-IS with no warranty, either express or
  implied.
  
  This software is distributed under license and may not be copied,
  modified or distributed except as expressly authorized under the terms
  of the license contained in the file LICENSE in this distribution.
  
  For more information about licensing, please refer to
  http://www.ghostscript.com/licensing/. For information on
  commercial licensing, go to http://www.artifex.com/licensing/ or
  contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  San Rafael, CA  94903, U.S.A., +1(415)492-9861.
*/

/* $Id$ */
/* Definitions for using assert in ghostscript code */

/* 
 * The use of assert (even in release code) is acceptable in cases 
 * where the assertion failure is clearly a logic error in the code, 
 * rather than an exception case from, say, invalid input date. 
 * An assert is especially useful when catching the assertion early 
 * prevents a crash or more mysterious error condition later.
 *
 * The system assert macro is troublesome in release code.
 * On some systems (e.g. when GS is running from a Windows service) 
 * it can result in an invisible dialog box which blocks the program.
 *
 * Ghostscript code should use the GS_ASSERT macro rather than
 * the system assert macro.
 * In debug code, GS_ASSERT uses the system assert macro.
 * In release code, GS_ASSERT writes a message to stderr and continues.
 * Note that GS_ASSERT does generate code in release builds,
 * and will slow down execution.
 */

#ifndef assert__INCLUDED
# define assert__INCLUDED

# include <assert.h>

/* ------ Assert ------ */
# ifdef DEBUG
#  define GS_ASSERT(exp) assert(exp)
# else
#  define GS_ASSERT(exp) (void)( (exp) || (eprintf3("Assertion failed!\n File: %s\n Line: %d\n Expression: %s\n", __FILE__, __LINE__, #exp)) )
# endif
 
#endif /* assert__INCLUDED */