Jump to content
  • Advertisement
Sign in to follow this  
Aluthreney

Error in code

This topic is 2532 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was copying the code from a book about using #undef. This is the code:

#define DemoVersion
#define DOS_VERSION 5
#include <iostream>
using namespace std;

int main()
{
cout << "Checking on the definitions of DemoVersion, DEMO_VERSION_and WINDOWS_VERSION...\n";

#ifdef DemoVersion
cout << "DemoVersion defined.\n";

#else
cout << "DemoVersion not defined!\n";
#endif

#ifndef DOC_VERSION
cout << "DOS_VERSION not defined.\n";

#else
cout << "DOS_VERSION defined as: " << DOS_VERSION << endl;
#endif

#ifdef WINDOWS_VERSION
cout << "WINDOWS_VERSION defined.\n";

#else
cout << "WINDOWS_VERSION not defined!\n";
#endif

#undef DOS_VERSION

#ifdef DemoVersion
cout << "DemeVersion defined.\n";

#else
cout << "DemoVersion not defined!\n";
#endif

#ifndef DOS_VERSION
cout << "DOS_VERSION not defined!\n";

#else
cout << "DOS_VERSION defined as: " << DOS_VERSION << endl;
#endif

#if_Tz'WINDOWS_VERSION -------------------------------------------------------------------------------------------------------
cout << "WINDOWS_VERSION defined.\n";

#else
cout << "WINDOWS_VERSION was not defined!\n";
#endif

cout << "Done.\n";
return 0;
}


When I compiled the program it gave me an error on the line that is filled with lines. the error is:

- 47 error: invalid preprocessing directive #if_Tz

- 47 warning: missing terminating ' character

- 50 error: #else without #if

- 52 error: #endif without #if

(I figured the last two error are due to the other two and therefore aren't that important since they will solve themselves when the first error is corrected, but I posted them anyway in case I'm wrong.)

I've copied the code exactly the way it is in the book.
Can anyone tell me what the problem is?

Share this post


Link to post
Share on other sites
Advertisement


#if_Tz'WINDOWS_VERSION -------------------------------------------------------------------------------------------------------
cout << "WINDOWS_VERSION defined.\n";



That line is the problem, it looks like you may have held down a key on accident and typed a bunch of _ in there or maybe the code on the CD was bad =)
it should be:

#ifdef WINDOWS_VERSION
cout << "WINDOWS_VERSION defined.\n";


edit: fixed my code error =)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!