YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Add SQUIRREL_VERSION_NUM for preprocessor version check
Nimrof
#1 Posted : Sunday, August 28, 2011 9:19:17 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/10/2008(UTC)
Posts: 24
Location: Telemark, Norway

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
Hi

For compatibility from version to version I see a lack of a easy way to check the API versions using the preprocessor. A defined version "variable" like SQUIRREL_VERSION_NUM ('_NUM' taken from lua) it can be very handy when making code that should work independent of different versions v2.x and v3.x.

To make it short I want to do something like this

Code:

#if (SQUIRREL_VERSION_NUM >= 300) //300 == version 3.0.0
//Do stuff using the v3 API
#elif (SQUIRREL_VERSION_NUM >= 200)
//Do stuff using the v2 API
#endif


Edit: The code below wont work as the preprocessor can not work with strings in that way
Using version strings I can not find other ways than checking every version string from 3.0 to 2.0 and then using the newly defined SQUIRREL_VERSION_NUM to do the job.

Code:

#if SQUIRREL_VERSION == _SC("Squirrel 3.0 stable")
#define SQUIRREL_VERSION_NUM 300
#elif SQUIRREL_VERSION == _SC("Squirrel 2.2.4 stable")
#define SQUIRREL_VERSION_NUM 224
#elif SQUIRREL_VERSION == _SC("Squirrel 2.2.3 stable")
#define SQUIRREL_VERSION_NUM 223
//...Do this for all squirrel versions strings
#else
#error "Unknown Squirrel version"
#endif


Please ask if anything does not make sense (the code is not tested so there may be syntax errors)
fagiano
#2 Posted : Sunday, August 28, 2011 9:39:48 PM(UTC)
Rank: Advanced Member

Groups: Registered, Administrators
Joined: 6/11/2005(UTC)
Posts: 1,056

Thanks: 0 times
Was thanked: 78 time(s) in 60 post(s)
Hi, ok this makes sense I'll see to add it to the next version.

thank you

ciao
Alberto
Follow me on Twitter @squirrellang
atai
#3 Posted : Friday, September 23, 2011 6:31:11 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 8/16/2005(UTC)
Posts: 310

Thanks: 18 times
Was thanked: 18 time(s) in 14 post(s)

Alberto, is there plan to make Squirre 2.x release with this?

fagiano wrote:
Hi, ok this makes sense I'll see to add it to the next version.

thank you

ciao
Alberto

cue
#4 Posted : Wednesday, October 19, 2011 12:47:50 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 1/3/2011(UTC)
Posts: 60
Man

Thanks: 0 times
Was thanked: 4 time(s) in 4 post(s)
What about a sq_getlinkedversion()?

I'm dynamically linking to squirrel and would like being able to verify the version of the linked library.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.153 seconds.