[metapost] Segfault when trying to access mp_svg_ship_out!

Shriramana Sharma samjnaa at gmail.com
Fri Aug 10 14:51:47 CEST 2012

BTW the same source file also reveals a(nother) bug in the headers:

If you don't #include stdlib.h before you include the MP headers (even
the basic mplib.h), you get errors about size_t not being known etc.

I remember having read that it is good programming practice w.r.t.
libraries to not *require* any one header to be included before
another -- every header should #include any other header that it
absolutely needs for it to be meaningful.

Of course, #ifndef and friends are there to prevent duplicate definition ...

... um ...

... ouch! The MPLib header files do NOT have the standard #ifndef
MPLIB_H #define MPLIB_H decorations! :-(

So that's *two* bugs --

1) #include stdlib.h at the head of mplib.h, and

2) add #ifndef MPLIB_H etc decorations to all headers in the library!
(or the CWeb source that is supposed to create these*)

You want me to report these at the tracker?

[* = Every now and then I'm finding difficulties caused by the CWeb
source -- I'm sure you guys would have not forgotted the #ifndef stuff
if you had manually written the .h files. :-( Wonder if there will be
a yes-this-is-C rewrite of MPLib in the future...]

Shriramana Sharma

More information about the metapost mailing list