[asterisk-dev] asterisk_version_num define need to be fixed ?

Matteo Brancaleoni mbrancaleoni at espia.it
Tue Jan 9 10:26:30 MST 2007


Asterisk 1.2 introduced a version.h header with a couple of #defines
that seemed to be what was needed to finally be able to write
multi-version modules.

Ok, let's give them a look:

#define ASTERISK_VERSION "1.2.5"
#define ASTERISK_VERSION_NUM 010205

The former is a string... okay, fine...

The latter one supposes to be an integer, 
encoding the version number, to be used, for example, for:

#if ASTERISK_VERSION_NUM < 010205
...
#endif

But that leading zero is quite suspect.
Few use octal integers everyday, but in C, 
numbers prefixed with a zero are just that, octal constants.

Uhm... ok... it's an octal constant... 3 bits for each digit... 
sounds fine... 
BUT...

What happens when you want to encode 1.2.8 ?

#define ASTERISK_VERSION "1.2.8"
#define ASTERISK_VERSION_NUM 010208

Ohoh... that's NOT a valid octal constant... tada... every module using
that preprocessor symbol does not compile anymore :)

So... that symbol is useless... if you use it your code won't compile on
1.2.8, 1.2.9, 1.4.8, 1.4.9 and so on.

What can be done to fix that?

Greetings,
Matteo

P.S.
Thanks to vihai to poiting this out.



More information about the asterisk-dev mailing list