OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Apr 20, 2024 8:45 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Help with code
PostPosted: Sun Nov 17, 2002 10:22 pm 
I am trying to run this piece of code and it won't work. It doesn't like the:
Code:
#error WARNING: This is not the right version to use

Why am I doing wrong.

Heres the code:
Code:
#if ((__VER__!=__major__) || ((__VER__ == __major__ ) && (__VER_MINOR__ < __minor__ )))
#error WARNING: This is not the right version to use
#endif


Top
  
 
 Post subject: Re:Help with code
PostPosted: Sun Nov 17, 2002 11:05 pm 
By the way, I forgot to add this:
Code:
#define __major__ 1
#define __minor__ 0


Top
  
 
 Post subject: Re:Help with code
PostPosted: Mon Nov 18, 2002 5:32 am 
Is this in C++?


Top
  
 
 Post subject: Re:Help with code
PostPosted: Mon Nov 18, 2002 9:41 am 
Yep...C++...(or C)

...


what I do is:

#ifdef SOME_DEF
#error THE ERROR!

#elif defined( SOMEDEF2 )
#error !!!
#endif


Top
  
 
 Post subject: Re:Help with code
PostPosted: Mon Nov 18, 2002 12:28 pm 
helped?


Top
  
 
 Post subject: Re:Help with code
PostPosted: Mon Nov 18, 2002 2:51 pm 
What actual Compiler are you using... then i might be able to help you


Top
  
 
 Post subject: Re:Help with code
PostPosted: Mon Nov 18, 2002 5:45 pm 
Sorry smguy...but you know C++? I didn't know that...

If you really know C++...why didn't you know what that:

#define

was?


Top
  
 
 Post subject: Re:Help with code
PostPosted: Mon Nov 18, 2002 7:12 pm 
Ah but that is where you are wrong my freind... many different languages use the #define command....TAKE AGI FOR INSTANCE... :P


Top
  
 
 Post subject: Re:Help with code
PostPosted: Mon Nov 18, 2002 7:24 pm 
Ohhhhhh... sorry :)


Top
  
 
 Post subject: Re:Help with code
PostPosted: Mon Nov 18, 2002 8:18 pm 
Why would that work?...is that even what he asked?


Top
  
 
 Post subject: Re:Help with code
PostPosted: Tue Nov 19, 2002 2:44 am 
beyondsociety, if __VER__ is 1.0, it will pass the first test because 1 does NOT equal 1.0. the second test will fail because it is neither 1 nor 0. it can only pass iff __VER__ is simultaneously 1 AND less than 0. obviously, that's very hard to do.

i don't know what compiler you're using, so i don't know what __VER__ contains, but you're testing the same define against two other unequal defines.

i'd take that code out.


Top
  
 
 Post subject: Re:Help with code
PostPosted: Tue Nov 19, 2002 5:51 am 
I agree with this guy... but until so... just try and make do..is this all in the immeadite where you are finding this?


Top
  
 
 Post subject: Re:Help with code
PostPosted: Wed Nov 20, 2002 10:57 am 
Here's what I did for integers in pk0.7:

#define FULLVERSION 0
#define VERSIONDOT 7

Print( FULLVERSION ); Print( "." ); Print( VERSIONDOT );

Output:

0.7


Top
  
 
 Post subject: Re:Help with code
PostPosted: Thu Nov 21, 2002 11:26 am 
Tom, that is not what I meant. I already know how to do that.

What I meant was, I want to check to see if my code is a certain version. If its the right version, then it will run. If its not the right version, it errors out.

Could someone give me a example.


Top
  
 
 Post subject: Re:Help with code
PostPosted: Thu Nov 21, 2002 12:00 pm 
do what I did and just check each Define.


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group