compile hello world

B

Brian

Greetings:
I am trying to compile the following code via command line.
It compiles just fine in visual studio 2002 v7 so i took looked at the
properties and i

got the following command line options, but when i try to compile i
get the errors listed

below. Can anyone give me a suggestion on how to compile this program?

#include <iostream>

using namespace std;

int main() {
cout << "Hello World" << endl;
return 0;
}

cl /nologo /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Gm
/EHsc /RTC1 /MLd

/Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /nologo /c /Wp64 /ZI /TP
example.cpp


c:\Program Files\Microsoft Visual Studio
..NET\Vc7\include\xstring(1286) : warnin
g C4346: 'std::basic_string<_Elem,_Traits,_Ax>::size_type' : dependent
name is n
ot a type
prefix with 'typename' to indicate a type
c:\Program Files\Microsoft Visual Studio
..NET\Vc7\include\xstring(1286) : error
C2143: syntax error : missing ';' before
'std::basic_string<_Elem,_Traits,_Ax>::
npos'
c:\Program Files\Microsoft Visual Studio
..NET\Vc7\include\xstring(1286) : error
C2501: 'std::basic_string<_Elem,_Traits,_Ax>::size_type' : missing
storage-class
or type specifiers
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\typeinfo.h(53) :
error C2989: 'type_info' : template class has already been defined as
a non-temp
late class
predefined C++ types (compiler internal)(96) : see declaration
of 'type_
info'
c:\Program Files\Microsoft Visual Studio
..NET\Vc7\include\xlocinfo.h(48) : error
C2143: syntax error : missing ';' before 'identifier'
c:\Program Files\Microsoft Visual Studio
..NET\Vc7\include\xlocinfo.h(48) : warni
ng C4091: 'typedef ' : ignored on left of '_Collvec' when no variable
is declare
d
c:\Program Files\Microsoft Visual Studio
..NET\Vc7\include\xlocinfo.h(48) : fatal
error C1004: unexpected end of file found

thanks,

brian
 
U

Unforgiven

Brian said:
Greetings:
I am trying to compile the following code via command line.
It compiles just fine in visual studio 2002 v7 so i took looked at the
properties and i

got the following command line options, but when i try to compile i
get the errors listed

below. Can anyone give me a suggestion on how to compile this program?

This newsgroup covers only the standard C++ language, of which compiler
command line options are not a part. Please consult a newsgroup where your
query is on topic, such as the microsoft.public.* groups.
 
V

Victor Bazarov

Brian said:
Greetings:
I am trying to compile the following code via command line.
It compiles just fine in visual studio 2002 v7 so i took looked at the
properties and i

got the following command line options, but when i try to compile i
get the errors listed

below. Can anyone give me a suggestion on how to compile this program?

#include <iostream>

using namespace std;

int main() {
cout << "Hello World" << endl;
return 0;
}

The code is fine. The errors you get are due to either installation
issues or wrong command-line options you're passing to the compiler.

Alas, command-line options of different compilers are off-topic here.
Please ask in microsoft.public.vc.language or some other relevant
VC++ newsgroup.

Victor
 
A

Allan Bruce

Brian said:
Greetings:
I am trying to compile the following code via command line.
It compiles just fine in visual studio 2002 v7 so i took looked at the
properties and i

got the following command line options, but when i try to compile i
get the errors listed

below. Can anyone give me a suggestion on how to compile this program?

#include <iostream>

using namespace std;

int main() {
cout << "Hello World" << endl;
return 0;
}

In visual studio, endl is not suppported. I usually use ENDL and #define
ENDL "\n"
Allan
 
A

Allan Bruce

In visual studio, endl is not suppported. I usually use ENDL and
#define
Don't be ridiculous. VC++ supports endl just fine.

Newbie alert!! Previous post is in error.
But please take Microsoft compiler questions to the Microsoft newsgroups.

ok, please forgive me, I forgot to use std::endl, since I dont declare to
use a namesapce.
BTW, Which post is in error?
 
G

Gary Labowitz

Allan Bruce said:
In visual studio, endl is not suppported. I usually use ENDL and #define
ENDL "\n"

Don't be ridiculous. VC++ supports endl just fine.

Newbie alert!! Previous post is in error.
But please take Microsoft compiler questions to the Microsoft newsgroups.
 
J

James Lothian

Allan Bruce wrote:
[snip]
In visual studio, endl is not suppported. I usually use ENDL and #define
ENDL "\n"
Allan

Eh?? Are you sure about that? I've been using endl for ages with VC++.
Look it
up in MSDN library.

James
 
U

Unforgiven

Allan said:
In visual studio, endl is not suppported. I usually use ENDL and
#define ENDL "\n"

In addition to the fact that std::endl is supported just fine in all
versions of VC I've ever used, as other posters have already stated, I would
like to add that your macro is NOT equivalent to std::endl.

What std::endl actually does is insert a new line, and flush the buffer. So
your macro would need to be (if it would be needed, which it's not):
#define ENDL "\n" << std::flush

Ah... talk of endl and flush always takes me back to first year at Uni: my
programming course instructor would insist you have to use std::endl instead
of just "\n" in case the computer explodes right after the statement. Yep,
those were his exact words (well, not exactly, he said it in Dutch, but you
get the idea). ^_^

More realistically, I've had situations where a line would not show up if
the program terminated unexpectedly after the std::cout statement if I
didn't use endl or flush.
 
F

Faz

I am trying to compile the following code via command line.
It compiles just fine in visual studio 2002 v7 so i took looked at the
properties and i

got the following command line options, but when i try to compile i
get the errors listed

below. Can anyone give me a suggestion on how to compile this program?

[gripping list of errors omitted]



There is a batch file provided in the installation called something like
vcvars.bat, if I recall correctly. This sets up the environment variables so
that the standard headers and the libraries can be found by the compiler and
linker. Run that batch file within the console session before executing
your compiler. Maybe that's your problem.. for some weird reason I didn't
get the urge to comb through the errors :p

Good luck,

Fazl
 

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,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top