By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,226 Members | 1,193 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,226 IT Pros & Developers. It's quick & easy.

Changing case "message" to "MESSAGE"

P: n/a
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

--
Nov 15 '07 #1
Share this Question
Share on Google+
13 Replies


P: n/a
On 2007-11-15 10:49:03 -0500, Michael Bell <mi*****@beaverbell.co.uksaid:
>
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".

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

Nov 15 '07 #2

P: n/a
Michael Bell wrote:
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.hor 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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 15 '07 #3

P: n/a
In message <2007111510525016807-pete@versatilecodingcom>
Pete Becker <pe**@versatilecoding.comwrote:
On 2007-11-15 10:49:03 -0500, Michael Bell <mi*****@beaverbell.co.uksaid:
>>
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".
I was unable to test this theory because it won't complile without
#include <vcl.hat 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
--
Nov 15 '07 #4

P: n/a
In message <fh**********@news.datemas.de>
"Victor Bazarov" <v.********@comAcast.netwrote:
Michael Bell wrote:
>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.hor 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

--
Nov 15 '07 #5

P: n/a
Michael Bell wrote:
Working my way through Koenig & Moo "Accelerated C++"
system("PAUSE");
If that book really teaches you to do that, throw it away and buy a
better one.
Nov 15 '07 #6

P: n/a
Juha Nieminen wrote:
Michael Bell wrote:
>Working my way through Koenig & Moo "Accelerated C++"
>system("PAUSE");

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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 15 '07 #7

P: n/a
In message <47**********************@news.song.fi>
Juha Nieminen <no****@thanks.invalidwrote:
Michael Bell wrote:
>Working my way through Koenig & Moo "Accelerated C++"
>system("PAUSE");
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
--
Nov 15 '07 #8

P: n/a
Michael Bell wrote:
In message <47**********************@news.song.fi>
Juha Nieminen <no****@thanks.invalidwrote:
>Michael Bell wrote:
>>Working my way through Koenig & Moo "Accelerated C++"
>>system("PAUSE");
> 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/
Use the command line version of the compiler.
Nov 15 '07 #9

P: n/a
On 2007-11-15 20:22, Michael Bell wrote:
In message <47**********************@news.song.fi>
Juha Nieminen <no****@thanks.invalidwrote:
>Michael Bell wrote:
>>Working my way through Koenig & Moo "Accelerated C++"
>>system("PAUSE");
> 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/
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.

--
Erik Wikström
Nov 15 '07 #10

P: n/a
"Michael Bell" <mi*****@beaverbell.co.ukwrote in message
news:6d********************@michael.beaverbell.co. uk...
In message <2007111510525016807-pete@versatilecodingcom>
Pete Becker <pe**@versatilecoding.comwrote:
>On 2007-11-15 10:49:03 -0500, Michael Bell <mi*****@beaverbell.co.uk>
said:
>>>
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".

I was unable to test this theory because it won't complile without
#include <vcl.hat 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
Nov 16 '07 #11

P: n/a
In message <o8**************@newsfe06.lga>
"Jim Langston" <ta*******@rocketmail.comwrote:
"Michael Bell" <mi*****@beaverbell.co.ukwrote in message
news:6d********************@michael.beaverbell.co. uk...
>In message <2007111510525016807-pete@versatilecodingcom>
Pete Becker <pe**@versatilecoding.comwrote:
>>On 2007-11-15 10:49:03 -0500, Michael Bell <mi*****@beaverbell.co.uk>
said:
>>>>
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".

I was unable to test this theory because it won't complile without
#include <vcl.hat 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
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


--
Nov 16 '07 #12

P: n/a
On Nov 15, 8:22 pm, Michael Bell <mich...@beaverbell.co.ukwrote:
In message <473c929c$0$3198$39db0...@news.song.fi>
Juha Nieminen <nos...@thanks.invalidwrote:
Michael Bell wrote:
Working my way through Koenig & Moo "Accelerated C++"
system("PAUSE");
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/
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.)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Nov 16 '07 #13

P: n/a
On 2007-11-16 05:18:08 -0500, Michael Bell <mi*****@beaverbell.co.uksaid:
In message <o8**************@newsfe06.lga>
"Jim Langston" <ta*******@rocketmail.comwrote:
>"Michael Bell" <mi*****@beaverbell.co.ukwrote in message
news:6d********************@michael.beaverbell.co .uk...
>>In message <2007111510525016807-pete@versatilecodingcom>
Pete Becker <pe**@versatilecoding.comwrote:

On 2007-11-15 10:49:03 -0500, Michael Bell <mi*****@beaverbell.co.uk>
said:

>
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".

I was unable to test this theory because it won't complile without
#include <vcl.hat 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

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.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

Nov 16 '07 #14

This discussion thread is closed

Replies have been disabled for this discussion.