Changing case "message" to "MESSAGE"

M

Michael Bell

Working my way through Koenig & Moo "Accelerated C++" and using
Borlang Builder 5 (but that is probably not relevant) I reached
exercise 1-1 and typed in

#include <vcl.h>
#pragma hdrstop
#include <iostream>
#include <string>

int main(int argc, char*argv[]}
{
const std::string hello = "Hello" // This by itself compiled
const std::string message = "Hello" // and other stuff which I have
//left out here.
system("PAUSE");
return 0;

}

But I left caps lock on, and by mistake typed MESSAGE, and it didn't
compile. I retyped message in lower case it did compile! I was
astonished. I thought you could give variables any name you liked,
capitalised or not.

What's the explanation? Is MESSAGE a reserved word?

Michael Bell

--
 
P

Pete Becker

But I left caps lock on, and by mistake typed MESSAGE, and it didn't
compile. I retyped message in lower case it did compile! I was
astonished. I thought you could give variables any name you liked,
capitalised or not.

What's the explanation? Is MESSAGE a reserved word?

No. It's probably a macro that's defined in "vcl.h".
 
V

Victor Bazarov

Michael said:
Working my way through Koenig & Moo "Accelerated C++" and using
Borlang Builder 5 (but that is probably not relevant) I reached
exercise 1-1 and typed in

#include <vcl.h>
#pragma hdrstop
#include <iostream>
#include <string>

int main(int argc, char*argv[]}
{
const std::string hello = "Hello" // This by itself compiled
const std::string message = "Hello" // and other stuff which I have
//left out here.
system("PAUSE");
return 0;

}

But I left caps lock on, and by mistake typed MESSAGE, and it didn't
compile. I retyped message in lower case it did compile! I was
astonished. I thought you could give variables any name you liked,
capitalised or not.

What's the explanation? Is MESSAGE a reserved word?

First, I don't see any "MESSAGE" used in your text.

Second, why do you need 'argc' and 'argv' if you're not using them?

Third, I doubt Koenig's book recommends <vcl.h> or hdrstop pragma,
what if you just drop those?

Forth, every declaration statement need to end with a semicolon.

Fifth, 'MESSAGE' (if you did in fact use it somewhere) _can_ be
a macro in your compiler's environment.

V
 
M

Michael Bell

In message <2007111510525016807-pete@versatilecodingcom>
Pete Becker said:
On 2007-11-15 10:49:03 -0500, Michael Bell <[email protected]> said:
No. It's probably a macro that's defined in "vcl.h".

I was unable to test this theory because it won't complile without
#include <vcl.h> at the top - the error message gives a linker error
and quotes vcl.h. And I can't trace A macro "MESSAGE" in "Borland
Builder C++ 5 for Dummies" - but that's not proof.

It doesn't matter too much. I can still get on with the book. But I
don't like it when something happens that I don't understand. But your
suggestion allows me to lay that worry aside.

Michael Bell
--
 
M

Michael Bell

In message <[email protected]>
"Victor Bazarov said:
Michael said:
Working my way through Koenig & Moo "Accelerated C++" and using
Borlang Builder 5 (but that is probably not relevant) I reached
exercise 1-1 and typed in

#include <vcl.h>
#pragma hdrstop
#include <iostream>
#include <string>

int main(int argc, char*argv[]}
{
const std::string hello = "Hello" // This by itself compiled
const std::string message = "Hello" // and other stuff which I have
//left out here.
system("PAUSE");
return 0;

}

But I left caps lock on, and by mistake typed MESSAGE, and it didn't
compile. I retyped message in lower case it did compile! I was
astonished. I thought you could give variables any name you liked,
capitalised or not.

What's the explanation? Is MESSAGE a reserved word?
First, I don't see any "MESSAGE" used in your text.

I quoted it in the correct, lower case.
Second, why do you need 'argc' and 'argv' if you're not using them?

Borland loads them by default. It runs even it I remove them. I have
no idea what they do.
Third, I doubt Koenig's book recommends <vcl.h> or hdrstop pragma,
what if you just drop those?
Forth, every declaration statement need to end with a semicolon.

Yes, I missed them out. But they were there.
Fifth, 'MESSAGE' (if you did in fact use it somewhere) _can_ be
a macro in your compiler's environment.

I can't trace it in "Borland Builder C++ 5 for Dummies." But at least
I know that I haven't misunderstood the main meat of the lessons.

Michael Bell

--
 
V

Victor Bazarov

Juha said:
If that book really teaches you to do that, throw it away and buy a
better one.

Nah... Just caint be. But a better compiler or IDE might actually
serve Michael well.

V
 
M

Michael Bell

In message <[email protected]>
If that book really teaches you to do that, throw it away and buy a
better one.

That's in "C++ for Dummies". Koenig and Moo assume that somebody who
knows what he is doing has set your computer up for you. If you run
their programs as they show on the page, the .exe opens and closes in
a tenth of a second. You've got to do something to hold it there long
enough to see it. If you think this is bad, what should I do better/

Michael Bell


--
 
R

red floyd

Michael said:
In message <[email protected]>



That's in "C++ for Dummies". Koenig and Moo assume that somebody who
knows what he is doing has set your computer up for you. If you run
their programs as they show on the page, the .exe opens and closes in
a tenth of a second. You've got to do something to hold it there long
enough to see it. If you think this is bad, what should I do better/

Use the command line version of the compiler.
 
G

Guest

In message <[email protected]>



That's in "C++ for Dummies". Koenig and Moo assume that somebody who
knows what he is doing has set your computer up for you. If you run
their programs as they show on the page, the .exe opens and closes in
a tenth of a second. You've got to do something to hold it there long
enough to see it. If you think this is bad, what should I do better/

If you use Visual C++ 2005 Express you can use Ctrl+F5 when running your
program to get a command windows that does not disappear. If you use
another IDE look into making it run a bat-file which launches the
application and then pauses instead of running the application directly.
 
J

Jim Langston

Michael Bell said:
In message <2007111510525016807-pete@versatilecodingcom>



I was unable to test this theory because it won't complile without
#include <vcl.h> at the top - the error message gives a linker error
and quotes vcl.h. And I can't trace A macro "MESSAGE" in "Borland
Builder C++ 5 for Dummies" - but that's not proof.

It doesn't matter too much. I can still get on with the book. But I
don't like it when something happens that I don't understand. But your
suggestion allows me to lay that worry aside.

So opne up hte file vcl.h and search for MESSAGE
 
M

Michael Bell

In message <o85%[email protected]>
So opne up hte file vcl.h and search for MESSAGE

I can't search vcl.h itself, or at least I don't know how to, but I
have searched the help for it, and there is a macro called "MESSAGE"
(UPPER CASE) so your suspicions are well founded and I know how I have
tripped over an obstacle that I had no reason to suspect was there.
All sorted then. Thank you everybody.

Michael Bell




--
 
J

James Kanze

That's in "C++ for Dummies". Koenig and Moo assume that
somebody who knows what he is doing has set your computer up
for you. If you run their programs as they show on the page,
the .exe opens and closes in a tenth of a second. You've got
to do something to hold it there long enough to see it. If you
think this is bad, what should I do better/

Find out how to use your IDE? Or use a different one? Erik
Wikström has posted how to use Visual Studio correctly. If
you're IDE doesn't have something similar, it's time to change
it (and Visual Studio is free, as are some others).

(Once you start programming professionally, of course, you'll
drop the IDE in favor of more powerful tools. But while
learning... having to learn all of those tools just to compile a
C++ program is perhaps biting off too much at once.)
 
P

Pete Becker

In message <o85%[email protected]>



I can't search vcl.h itself, or at least I don't know how to, but I
have searched the help for it, and there is a macro called "MESSAGE"
(UPPER CASE) so your suspicions are well founded and I know how I have
tripped over an obstacle that I had no reason to suspect was there.
All sorted then. Thank you everybody.

A more general test would be to add

#undef MESSAGE

after the #include directive. But for simple programs like this one,
you don't need vcl. And your code will compile without vcl. You have to
find the compiler settings that get rid of whatever non-standard thing
is getting in the way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top