473,323 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Want workaround for msvc compiler (VC++ 6.0).

I compile this program using Microsoft Visual C++ 6.0:

#include <cstdio>

int main()
{
std::printf("Hello world");
return 0;
}

It gives me the following error message:

Main.cpp
C:\Projects\Examples\Main.cpp(5): error C2653: 'std': is not a class or
namespace name

How do I stop this? Thanks.
Jul 23 '05 #1
6 1582
Apparently v6.0 doesn't put printf in the std namespace then. You could the
traditional C program:

#include<stdio.h>

int main(int argc, char* argv[])
{
printf("Hello World\n");
return 0;
}

But in C++ it would look more like:

#include<iostream>

int main(int argc, char* argv[])
{
std::cout << "Hello World" << std::endl;
return 0;
}
Jul 23 '05 #2
"Phil Staite" <fo*******@nospam.for.me> wrote in message
news:39********************@pcisys.net...
Apparently v6.0 doesn't put printf in the std namespace then. You could
the
traditional C program:

#include<stdio.h>

int main(int argc, char* argv[])
{
printf("Hello World\n");
return 0;
}

But in C++ it would look more like:

#include<iostream>

int main(int argc, char* argv[])
{
std::cout << "Hello World" << std::endl;
return 0;
}


Unfortunately v6.0 puts nothing from C in the std namespace. Example:

#include <iostream>
#include <cstdlib>

int main()
{
char c;
std::cin >> c;
std::cout << "Character is " << (std::isupper(c) ? "upper" : "lower") <<
" case" << std::endl;
return 0;
}

This generates the same error.
Jul 23 '05 #3
Jason Heyes wrote:
Unfortunately v6.0 puts nothing from C in the std namespace. Example:
Bad? I never use #include <cstdio> or #include <cstdlib>. Why should
one obfuscate C library names anyway?
#include <iostream>
#include <cstdlib>

int main()
{
char c;
std::cin >> c;
std::cout << "Character is " << (std::isupper(c) ? "upper" : "lower") <<
" case" << std::endl;
return 0;
}

This generates the same error.


Because isupper is probably a macro.

Jul 23 '05 #4
"Panjandrum" <pa********@spambob.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Jason Heyes wrote:
Unfortunately v6.0 puts nothing from C in the std namespace. Example:


Bad? I never use #include <cstdio> or #include <cstdlib>. Why should
one obfuscate C library names anyway?
#include <iostream>
#include <cstdlib>

int main()
{
char c;
std::cin >> c;
std::cout << "Character is " << (std::isupper(c) ? "upper" : "lower")
<<
" case" << std::endl;
return 0;
}

This generates the same error.


Because isupper is probably a macro.


isupper can be defined by a library as an inline function instead of a
macro.
Jul 23 '05 #5


Jason Heyes wrote:
I compile this program using Microsoft Visual C++ 6.0:

#include <cstdio>

int main()
{
std::printf("Hello world");
return 0;
}

It gives me the following error message:

Main.cpp
C:\Projects\Examples\Main.cpp(5): error C2653: 'std': is not a class or
namespace name

How do I stop this? Thanks.


VC++6 is broked in this regard, at least in the version you (and it
turns out I) have. The most portable work-around is to not use the new
header, but the "C compatibility" version.

#include <stdio.h>

int main()
{
printf("Hello world\n");
return 0;
}
That header is deprecated, but is liable to be part of the standard for
a long time to come. BTW, I added a new-line to the output string, you
should have that in yours as well.

Brian

Jul 23 '05 #6
Jason Heyes wrote:
I compile this program using Microsoft Visual C++ 6.0:

#include <cstdio>

int main()
{
std::printf("Hello world");
return 0;
}

It gives me the following error message:

Main.cpp
C:\Projects\Examples\Main.cpp(5): error C2653: 'std': is not a class or
namespace name

How do I stop this? Thanks.


How 'bout:

namespace std {
#include <cstdio>
} // namespace

Note that I haven't tried this myself...

--
Mike Smith
Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Syver Enstad | last post by:
I've downloaded both source distro, and binary installer. Installed python with the binary installer, when I attempted to compile mxDateTime (mxBase) for 2.3 with MSVC 6.0 I got an error that...
2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
1
by: Arkadiy Vertleyb | last post by:
Hi all, I have some complicated template code, which results in long symbol names. At some point I started getting LNK1179 error. The decorated name shown in this message contains exactly 256...
1
by: icedac | last post by:
I have some questions about template and c++ itself. ///////////////////////////////////////////////////////////////////////// q1) see follow c++ code, and compile. it's works only IntelC++8.1...
2
by: Pep | last post by:
The following code from the Loki TypeManip.h header file is causing problems with MSVC version 6.0 template <unsigned i> struct TypeTag { struct Inner {char c;}; typedef Inner X;...
6
by: Uli | last post by:
Hello, I'm trying to use a DLL (by static linking) which was compiled with Borland C++Builder (BCB) in Visual C++ (Visual-Studio 2003). All functions are declared with the directive 'extern...
1
by: Michael O'Brien | last post by:
Hola~ I'm developing a c++ library that contains python types and methods on Windows using MSVC .net 2003 and g++ on Linux. To compile on Linux, I just compile and I can use a debug compiled...
3
by: hsmit.home | last post by:
I spent way too much time on this and I must say, I was a little disgruntled with what has been posted on all the various Xalan C mailing lists. Everyone says there's a solution, but give next to...
17
by: fl | last post by:
Hi, I am learning C++ from the following C++ website, which has some very good small examples. For the second Fraction example, which has five files: Main.cpp Fraction.cpp Fraction.h...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.