1 Reply Latest reply on Feb 24, 2016 10:36 PM by garywiz

    Suggestion: Better preprocessor definition for checking WICED version

      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.

        • 1. Re: Suggestion: Better preprocessor definition for checking WICED version

          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.

          2 of 2 people found this helpful