473,563 Members | 2,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10708
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....@gm ail.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....@gm ail.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...@gmai l.com" <zaheer...@gmai l.comwrote:
On Mar 5, 3:56 pm, "santosh" <santosh....@gm ail.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....@gm ail.comwrote:
>>zaheer...@gma il.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...@gmai l.com" <zaheer...@gmai l.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
2967
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 spare the time, I would appreciate any comments (including words like evil and disgusting, if you think they are applicable :-}) on the example here....
4
7160
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 get the basics down as well as some examples displaying how to simply read and write. But the next step appears exponential. I haven never done...
2
3473
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 menus by customizing a toolbar. With this method you have to create a separate macro for every single menu and sub menu. The old method would allow...
3
3226
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
6425
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 Autoexec Macro looks like the way to go. Could someone please assist? Thank you very much! Mike
5
3476
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 the cursor was on in the datasheet at the time I executed the macro. So, the questions are: 1) In the macro, how to I get my hands on the record...
0
2035
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 data again and delete the unwanted data and repeat few more times in new sheets. End product will be apprximately 7 or 8 sheets - 1 for Active...
2
1942
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 a month (cell B4) and the other has a year(cell B5). The macro that I have works great for searching just the month, but I don't know how to change...
1
3215
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 but it didn't work to reset the printer settings. Click on File then Print Click on Properties to get to the Printing Preferences and under...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.