mirror of
https://github.com/protobuf-c/protobuf-c.git
synced 2025-01-14 01:07:57 +08:00
Add version macros and library globals.
git-svn-id: https://protobuf-c.googlecode.com/svn/trunk@324 00440858-1255-0410-a3e6-75ea37f81c3a
This commit is contained in:
parent
64fad6b7f3
commit
b0d7d4a023
@ -11,6 +11,8 @@
|
||||
(srobbins99: Issue #68 Comment 1)
|
||||
- bug fix: fix for memory error is the required-field check fails.
|
||||
See Issue #63 for demo (w/ nice test case by dror.harari).
|
||||
- add PROTOBUF_C_{MAJOR,MINOR} for compile-time checks and
|
||||
protobuf_c_{major,minor} for checks about the running library. (Issue #53)
|
||||
|
||||
0.15:
|
||||
- make protobuf_c_message_init() into a function (Issue #49, daveb)
|
||||
|
@ -5,6 +5,9 @@ EXTRA_DIST = scripts pkgwriteinfo.in CMakeLists.txt LICENSE
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libprotobuf-c.pc
|
||||
|
||||
dist-hook:
|
||||
scripts/assert-version-numbers-match
|
||||
|
||||
# --- packages ---
|
||||
DEBARCH = `dpkg --print-architecture`
|
||||
deb:
|
||||
|
47
scripts/assert-version-numbers-match
Executable file
47
scripts/assert-version-numbers-match
Executable file
@ -0,0 +1,47 @@
|
||||
#! /usr/bin/perl
|
||||
|
||||
my $srcdir = $ENV{srcdir} || ".";
|
||||
|
||||
# get numbers from ChangeLog
|
||||
open IN, "<$srcdir/ChangeLog" or die "error opening $srcdir/ChangeLog";
|
||||
my $line = scalar(<IN>);
|
||||
if ($line =~ /\d+\.\d+ \((NOT.*)\)/) {
|
||||
die "ChangeLog still bears $1 (line 1)";
|
||||
}
|
||||
if ($line !~ /^(\d+\.\d+):\s*/) {
|
||||
die "ChangeLog parse error (line 1)";
|
||||
}
|
||||
my $changelog_version = $1;
|
||||
|
||||
# get numbers from protobuf-c.h
|
||||
open IN, "<$srcdir/src/google/protobuf-c/protobuf-c.h" or die "error opening $srcdir/src/google/protobuf-c/protobuf-c.h";
|
||||
while (<IN>)
|
||||
{
|
||||
if (/^\#define\s+PROTOBUF_C_MAJOR\s+(\d+)\s*$/)
|
||||
{ $c_major = $1; }
|
||||
if (/^\#define\s+PROTOBUF_C_MINOR\s+(\d+)\s*$/)
|
||||
{ $c_minor = $1; }
|
||||
}
|
||||
if (!defined $c_minor || !defined $c_major)
|
||||
{ die "missing PROTOBUF_C_MINOR or PROTOBUF_C_MAJOR in protobuf-c.h" }
|
||||
$c_version = "$c_major.$c_minor";
|
||||
|
||||
# get numbers from configure.ac
|
||||
open IN, "<$srcdir/configure.ac" or die "error opening $srcdir/configure.ac";
|
||||
my $line = scalar(<IN>);
|
||||
die "first line of configure.ac did not match our expectations"
|
||||
unless $line =~ /AC_INIT\(\[protobuf-c\], \[(\d+\.\d+)\]\)/;
|
||||
my $configure_version = $1;
|
||||
|
||||
|
||||
if ($c_version ne $configure_version || $c_version ne $changelog_version)
|
||||
{
|
||||
print STDERR <<"EOF";
|
||||
Versions mismatched:
|
||||
from configure.ac $configure_version
|
||||
from ChangeLog $changelog_version
|
||||
from protobuf-c.h $c_version
|
||||
EOF
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
@ -75,6 +75,9 @@
|
||||
|
||||
#include "protobuf-c.h"
|
||||
|
||||
unsigned protobuf_c_major = PROTOBUF_C_MAJOR;
|
||||
unsigned protobuf_c_minor = PROTOBUF_C_MINOR;
|
||||
|
||||
#define MAX_UINT64_ENCODED_SIZE 10
|
||||
|
||||
/* convenience macros */
|
||||
|
@ -59,6 +59,14 @@
|
||||
#define PROTOBUF_C_DEPRECATED
|
||||
#endif
|
||||
|
||||
/* The version of protobuf-c you are compiling against. */
|
||||
#define PROTOBUF_C_MAJOR 0
|
||||
#define PROTOBUF_C_MINOR 14
|
||||
|
||||
/* The version of protobuf-c you are linking against. */
|
||||
extern unsigned protobuf_c_major;
|
||||
extern unsigned protobuf_c_minor;
|
||||
|
||||
/* Define int32_t, int64_t, uint32_t, uint64_t, uint8_t.
|
||||
|
||||
Usually, just include <inttypes.h> to do the work.
|
||||
|
Loading…
x
Reference in New Issue
Block a user