vbcc and dynamic defines

3 posts / 0 new
Last post
walkero
walkero's picture
Offline
Last seen: 3 months 2 days ago
Joined: 2009-05-03 16:54
vbcc and dynamic defines

I try to create a version define dynamic based on other defines

I do something like:

  1. #define MAJOR_VERS 2
  2. #define MINOR_VERS 0
  3.  
  4. #define VERSION "$VER: myApp v" MAJOR_VERS "." MINOR_VERS

The problem is when I try to compile it with vbcc I get the following error when I try to use it

  1. warning 57 in line 1076 of "src/myAppGUI.c": , expected

the line where the error occurs is has the following

  1. MUIA_Application_Version, VERSION,

Any idea what I miss here?

salass00
salass00's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-02-03 11:27
Re: vbcc and dynamic defines

As the MAJOR_VERS and MINOR_VERS macros are numbers and not strings you need to either use an additional macro to add quotes around them like:

  1. #define MAJOR_VERS 2
  2. #define MINOR_VERS 0
  3.  
  4. #define _QUOTEME(x) #x
  5. #define QUOTEME(x) _QUOTEME(x)
  6.  
  7. #define VERSION "$VER: myApp v" QUOTEME(MAJOR_VERS) "." QUOTEME(MINOR_VERS)

or you could just define them as strings in the first place:

  1. #define MAJOR_VERS "2"
  2. #define MINOR_VERS "0"
  3.  
  4. #define VERSION "$VER: myApp v" MAJOR_VERS "." MINOR_VERS
walkero
walkero's picture
Offline
Last seen: 3 months 2 days ago
Joined: 2009-05-03 16:54
Re: vbcc and dynamic defines

@salass00
It works great. I don't believe how simple it is. And I was using same solution elsewhere. I think I was confused because of the error message.

Thank you again for your help.

Log in or register to post comments