Suggestion: Better preprocessor definition for checking WICED version

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

There is currently a preprocessor symbol defined for the WICED version that is inserted by Make using -DWICED_VERSION=\"3.5.1\".

This is really unfortunate because the C preprocessor does not permit strings to be used in conditionals.  You cannot say:

   #if WICED_VERSION == "3.5.1"

because that is not legal in the C preprocessor, and will not work.

What is the point of having a version macro if you can't use it to create conditional sections which are version sensitive?

Can I suggest, in future releases, that variables such as this be defined:

   #define WICED_VERSION_MAJOR 3

   #define WICED_VERSION_MINOR 5

or alternatively come up with an integral representation

   #define WICED_VERSION_NUMERIC 030501

That would really simplify life for those of us who have to support multiple releases.

0 Likes
1 Solution
Anonymous
Not applicable

I'm going to reply to my own suggestion here. 🙂   For people who want this, it is possible right now to create entries in your .mk file to do what I suggested.  It's a little convoluted, but it does the trick:

# We use the terminology of semantic versioning: MAJOR.MINOR.PATCH.

MY_WICED_VER_MAJOR := $(basename $(basename $(WICED_SDK_VERSION)))

MY_WICED_VER_MINOR := $(subst .,,$(suffix $(basename $(WICED_SDK_VERSION))))

MY_WICED_VER_PATCH := $(subst .,,$(suffix $(WICED_SDK_VERSION)))

GLOBAL_DEFINES  += MY_WICED_VER_MAJOR=$(MY_WICED_VER_MAJOR)

GLOBAL_DEFINES  += MY_WICED_VER_MINOR=$(MY_WICED_VER_MINOR)

GLOBAL_DEFINES  += MY_WICED_VER_PATCH=$(MY_WICED_VER_PATCH)

Then, in your header files you can say:

#if MY_WICED_VER_MAJOR >= 3 && MY_WICED_VER_MINOR >= 5

or some such.  It's worked for us.

View solution in original post

1 Reply
Anonymous
Not applicable

I'm going to reply to my own suggestion here. 🙂   For people who want this, it is possible right now to create entries in your .mk file to do what I suggested.  It's a little convoluted, but it does the trick:

# We use the terminology of semantic versioning: MAJOR.MINOR.PATCH.

MY_WICED_VER_MAJOR := $(basename $(basename $(WICED_SDK_VERSION)))

MY_WICED_VER_MINOR := $(subst .,,$(suffix $(basename $(WICED_SDK_VERSION))))

MY_WICED_VER_PATCH := $(subst .,,$(suffix $(WICED_SDK_VERSION)))

GLOBAL_DEFINES  += MY_WICED_VER_MAJOR=$(MY_WICED_VER_MAJOR)

GLOBAL_DEFINES  += MY_WICED_VER_MINOR=$(MY_WICED_VER_MINOR)

GLOBAL_DEFINES  += MY_WICED_VER_PATCH=$(MY_WICED_VER_PATCH)

Then, in your header files you can say:

#if MY_WICED_VER_MAJOR >= 3 && MY_WICED_VER_MINOR >= 5

or some such.  It's worked for us.