# C and C++ (Visual Studio 2K5)

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

## Recommended Posts

i just got the Visual Studio 2005 Beta 2 installed and now its giving me trouble. im trying to compile a project from VC++6 and i keep getting errors from cstdio, cstring and several other C files. ive narrowed it down and something just doesnt seem right. the compiler doesnt want to accept C functions such as fscanf or even scanf. any ideas of what i can do to get the compiler to accept C and C++ functions? [Edited by - adam17 on July 23, 2005 12:10:11 AM]

##### Share on other sites
Errors help a lot, along with code samples, otherwise we're shooting blind.

##### Share on other sites
I'd guess you've discovered the wonderful std namespace, and all the issues it raises.

When you include <cXXXX> all the functions/variables/etc are put into the std namespace. IIRC, this wasn't so for VC6 (or at least it didn't complain about it), but it is so for VC7.

What this means is that you'll have to:
a) Call everything as std::XXXX, eg. std::fscanf,
or b) Put 'using namespace std;' at the top of your source files,
or c) Include files as <XXXX.h> instead of <cXXXX>,
or d) Use VC6.

Peace,
Doc

##### Share on other sites
well i keep getting these errors:

Error	1	error C2143: syntax error : missing '{' before ':'	E:\Adam\Software\Visual Studio 8\VC\include\cstdio	25	Error	2	error C2059: syntax error : ':'	E:\Adam\Software\Visual Studio 8\VC\include\cstdio	25

i have 103 errors (the compiler gave up after 100 lol). anyway it takes me to those C functions and tells me the error is there.

at the top of my main header (its a custom header but the first to be included) contains the line:

using namespace std;

##### Share on other sites
"using namespace ___;" in header files at the file scope is a big no-no.

"using namespace ___;" before you're finished with all your headers can also cause problems and should be avoided.

This is what's likely causing your problems.

##### Share on other sites
i tried making the project from scratch, rather than just importing the .dsw file. BIG mistake apparently. anyway i have the program compiling but now its giving me tons of warnings about "'fopen' was declared depreciated". its doing it to fopen, fscanf and strcpy. im not sure what is going on here.

on another note, ive discovered just how broken VC++6 is and now im having to go back and fix a TON of stuff. damn u M$#### Share this post ##### Link to post ##### Share on other sites Quote:  anyway i have the program compiling but now its giving me tons of warnings about "'fopen' was declared depreciated". its doing it to fopen, fscanf and strcpy. im not sure what is going on here. As it says, they've been depreciated. What that means is while they'll work now, there's no guarantee that they'll be there at all in the future. Instead, you should be working with the likes of the iostream library, and std::string. Basically, I wouldn't worry about going through and converting your whole project over to using these different libraries, unless you plan to use this source in other projects into the future. From now on however, you should look to use the newer libraries instead whenever you work on a project. Quote:  on another note, ive discovered just how broken VC++6 is and now im having to go back and fix a TON of stuff. damn u M$

Visual Studio 6 came out before the first standardisation of C++, so it isn't exactly their fault. There was no fixed rulebook for everyone to stick by.

##### Share on other sites
Quote:
Original post by Nemesis2k2
Quote:
 anyway i have the program compiling but now its giving me tons of warnings about "'fopen' was declared depreciated". its doing it to fopen, fscanf and strcpy. im not sure what is going on here.

As it says, they've been depreciated. What that means is while they'll work now, there's no guarantee that they'll be there at all in the future. Instead, you should be working with the likes of the iostream library, and std::string.

Basically, I wouldn't worry about going through and converting your whole project over to using these different libraries, unless you plan to use this source in other projects into the future. From now on however, you should look to use the newer libraries instead whenever you work on a project.

To be precise, in VC++ 8.0 and above only they have deprecated a number of C routines mostly the C I/O routines for *Safe* variants of it that have "_s" on the front of the function's name for example fopen becomes fopen_s, its the Safe C & C++ library, it currently has nothing to with both C & C++ standards but the Safe C lib is being pushed to be part of the C standard basically this means its not portable at the moment. Read more about it here. You can still use the standard C routines still either just ignore the deprecation warnings or turn it off with the wright pragma (which i can't remember).

Quote:
 Original post by Docthis wasn't so for VC6 (or at least it didn't complain about it)

Well what ever the case VC++ 6.0 is has very poor standard compliance.

Quote:
 Original post by Docbut it is so for VC7.

Erm not that it matters but he using VC++ 8.0

Quote:
 Original post by DocWhat this means is that you'll have to:...or b) Put 'using namespace std;' at the top of your source files,

If you want to increase the chances of name collisions:

Quote:
 Original post by Docor c) Include files as instead of ,

Techincally no such files in standard C++, none have file extensions and in standard C no such files with a 'c' appended on the front of filename and do have file extension.

Quote:
 Original post by Docor d) Use VC6.

If you're a fool who wants to shoot him/her self in the foot.

##### Share on other sites
Nemesis2k2 -> when you say to use iostream are you talking about something like this:

ifstream infile;...infile>>/*some variable*/

heres another problem ive been experiencing (dunno if it has anything to do with my earlier problems) but i keep getting a problem with this line in lseek.c

_VALIDATE_CLEAR_OSSERR_RETURN((fh >= 0 && (unsigned)fh < (unsigned)_nhandle), EBADF, -1);

the error does not show up in the error list in the IDE. it only shows up when i compile and start running. ill show a screenshot if that helps.

clicky

[Edited by - adam17 on July 23, 2005 12:58:57 PM]

bump?

1. 1
2. 2
Rutin
25
3. 3
4. 4
5. 5

• 10
• 10
• 13
• 20
• 14
• ### Forum Statistics

• Total Topics
632950
• Total Posts
3009374
• ### Who's Online (See full list)

There are no registered users currently online

×