From 3248801a925449644071671dcd85e370303071b4 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Fri, 23 Jan 2015 17:04:14 +0100 Subject: Improve version information Add version number and string as macros and symbols. Version numbers can be easily compared, for example in the C preprocessor: #include #if CMARK_VERSION < 0x020200 #error Requires libcmark 2.2.0 or higher #endif Storing the version in a global variable allows to check the library version at runtime. For example: if (CMARK_VERSION != cmark_version) { warn("Compiled against libcmark %s, but using %s", CMARK_VERSION_STRING, cmark_version_string); } The version should be updated whenever the public API is changed. --- src/cmark.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/cmark.c') diff --git a/src/cmark.c b/src/cmark.c index 1d7a500..2ec9be9 100644 --- a/src/cmark.c +++ b/src/cmark.c @@ -6,6 +6,9 @@ #include "cmark.h" #include "buffer.h" +const int cmark_version = CMARK_VERSION; +const char cmark_version_string[] = CMARK_VERSION_STRING; + char *cmark_markdown_to_html(const char *text, int len) { cmark_node *doc; -- cgit v1.2.3