473,320 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Need help on Macro

Hi All,

I need to define a macro as follows

#define VERSION "1.0"
#ifdef (VERSION == "1.0")
#endif

main() {
}
I want to check the Version using macro . But the code compilation
gives error " macro names must be identifiers"
I know that #ifdef will work only for integers . Also I need this to
be done before main.
Need help for the same.

Regards,
Khan.

Mar 5 '07 #1
6 10694
za*******@gmail.com wrote:
Hi All,

I need to define a macro as follows

#define VERSION "1.0"
#ifdef (VERSION == "1.0")
#endif

main() {
}
I want to check the Version using macro . But the code compilation
gives error " macro names must be identifiers"
I know that #ifdef will work only for integers . Also I need this to
be done before main.
Need help for the same.
Try:

#define VERSION 1
#if VERSION == 1
/* ... */
#endif
int main(void) { /* ... */ return 0; }

Mar 5 '07 #2
On Mar 5, 3:56 pm, "santosh" <santosh....@gmail.comwrote:
zaheer...@gmail.com wrote:
Hi All,
I need to define a macro as follows
#define VERSION "1.0"
#ifdef (VERSION == "1.0")
#endif
main() {
}
I want to check the Version using macro . But the code compilation
gives error " macro names must be identifiers"
I know that #ifdef will work only for integers . Also I need this to
be done before main.
Need help for the same.

Try:

#define VERSION 1
#if VERSION == 1
/* ... */
#endif
int main(void) { /* ... */ return 0; }- Hide quoted text -

- Show quoted text -
I want to compare the different version like "1.1" "1.2" etc. But
these are not integers and the macro will not accept them.
So how do I compare the non integer values

Mar 5 '07 #3

za*******@gmail.com wrote:
On Mar 5, 3:56 pm, "santosh" <santosh....@gmail.comwrote:
zaheer...@gmail.com wrote:
Hi All,
I need to define a macro as follows
#define VERSION "1.0"
#ifdef (VERSION == "1.0")
#endif
main() {
}
I want to check the Version using macro . But the code compilation
gives error " macro names must be identifiers"
I know that #ifdef will work only for integers . Also I need this to
be done before main.
Need help for the same.
Try:

#define VERSION 1
#if VERSION == 1
/* ... */
#endif
int main(void) { /* ... */ return 0; }- Hide quoted text -

- Show quoted text -

I want to compare the different version like "1.1" "1.2" etc. But
these are not integers and the macro will not accept them.
So how do I compare the non integer values
The constant expression following an #if or #elif directive must
evaluate to an integral value. So, you can't do what you're asking.
Convert the version numbers into integer format. For example 1.1 will
be 11, 1.2 will be 12, 1.56 will be 156 etcetera.. Then you can write
the #if directive as I've shown earlier.

Mar 5 '07 #4
On 5 Mar, 11:22, "zaheer...@gmail.com" <zaheer...@gmail.comwrote:
On Mar 5, 3:56 pm, "santosh" <santosh....@gmail.comwrote:
zaheer...@gmail.com wrote:
Hi All,
I need to define a macro as follows
#define VERSION "1.0"
#ifdef (VERSION == "1.0")
#endif
main() {
}
I want to check the Version using macro . But the code compilation
gives error " macro names must be identifiers"
I know that #ifdef will work only for integers . Also I need this to
be done before main.
Need help for the same.
Try:
#define VERSION 1
#if VERSION == 1
/* ... */
#endif
int main(void) { /* ... */ return 0; }- Hide quoted text -
- Show quoted text -

I want to compare the different version like "1.1" "1.2" etc. But
these are not integers and the macro will not accept them.
So how do I compare the non integer values
Recognize that you are not talking about a single version number, but
2 - a major and a minor version number. Specify them as different
symbols and work from there.

Mar 5 '07 #5
santosh wrote, On 05/03/07 11:34:
za*******@gmail.com wrote:
>On Mar 5, 3:56 pm, "santosh" <santosh....@gmail.comwrote:
>>zaheer...@gmail.com wrote:
Hi All,
I need to define a macro as follows
#define VERSION "1.0"
#ifdef (VERSION == "1.0")
#endif
main() {
}
I want to check the Version using macro . But the code compilation
gives error " macro names must be identifiers"
I know that #ifdef will work only for integers . Also I need this to
be done before main.
Need help for the same.
Try:

#define VERSION 1
#if VERSION == 1
/* ... */
#endif
int main(void) { /* ... */ return 0; }- Hide quoted text -

- Show quoted text -
I want to compare the different version like "1.1" "1.2" etc. But
these are not integers and the macro will not accept them.
So how do I compare the non integer values

The constant expression following an #if or #elif directive must
evaluate to an integral value. So, you can't do what you're asking.
Convert the version numbers into integer format. For example 1.1 will
be 11, 1.2 will be 12, 1.56 will be 156 etcetera.. Then you can write
the #if directive as I've shown earlier.
Horrible. If you also do things with the version at run time version 1.2
will appear to be a long way before version 1.56. Yes, I do have code
comparing versions!

As mark_bluemel said, split the version in to separate identifiers for
major and minor. You can always use some preprocessor magic to stick
them back together as 1.56 when you need/want that.
--
Flash Gordon
Mar 5 '07 #6
On Mar 5, 11:22 am, "zaheer...@gmail.com" <zaheer...@gmail.comwrote:
I want to compare the different version like "1.1" "1.2" etc. But
these are not integers and the macro will not accept them.
So how do I compare the non integer values
#define VERSION_1_0 10000
#define VERSION_1_0_1 10001
#define VERSION_2_1_0 20100

#define VERSION VERSION_1_0_1

#if VERSION >= VERSION_1_0_1 && VERSION <= VERSION_2_1_0 || VERSION ==
VERSION_1_0
.... Things for version 1.0.1 to 2.1.0 or version 1.0
#endif
Mar 5 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Chris Reedy | last post by:
For everyone - Apologies for the length of this message. If you don't want to look at the long example, you can skip to the end of the message. And for the Python gurus among you, if you can...
4
by: Marc | last post by:
Hi all, I am trying to write an application where I need the ability to open an Excel spreadsheet and do basic read/write, insert rows, and hide/unhide rows. Using win32com I have been able to...
2
by: Pete | last post by:
In Access 95/97 I used to be able to create pull down menus (File,Edit ...) from a macro. It seems there used to be some wizard for that. However in Access 2000 it seems you have to build your...
3
by: bob | last post by:
Need help with c macro. Have this call in my c program. stub.c SYMBOL(ALPHA) << no, dont want to change this to any other form. SYMBOL(BETA) Need a macro to expand each of above to this.
6
by: Takeadoe | last post by:
Dear NG, Can someone assist me with writing the little code that is needed to run an update table query each time the database is opened? From what I've been able to glean from this group, the...
5
by: Bill | last post by:
This database has no forms. I am viewing an Access table in datasheet view. I'd like to execute a macro to execute a function (using "runcode"). In the function, I'll reading data from the record...
0
by: =?Utf-8?B?TGV0emRvXzF0?= | last post by:
I'd like to create a Macro that will sort some raw data, apprx 20k lines, remove some lines based upon a condition in a certain column. Then copy this data into a new spreadsheet and sort the ...
2
by: jotr | last post by:
I recently received help writing a search macro for excel, but now I am trying to change it up to use it in another spreadsheet, and I am having some troubles. I need it to search two cells one has...
1
by: sandyt57 | last post by:
I do Tech Support but do not know Visual Basic programming. In order to resolve a work process issue for one of our depts I need a macro that can do the following. I tried to create a macro in Word...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.