function cannot access 'xxx::xxx::operator <<' - c++

I have some code like:
namespace xxx {
namespace xxx {
struct local {
static void xxxxx(....) {
std::cout << "prints..........." <<std::endl;
}
}
}}
And I get errors as the title stated: "function cannot access 'xxx::xxx::operator <<'"
I created the MSVC project with visual studio 2005. While when I open the project in visual studio 2010, everyting works fine. But I need it working visual studio 2005, what might be the reason for it?
When I open it from Visual Studio 2010, I didn't change anything, it works directly.
And I know it is working with gcc as well. So something I can do for the msvc project to make it working without changing the code?

Related

C++ Hello world keeps giving me errors in Visual Studio 2019

I'm just trying to print hello world using C++ but all I get is build errors. The error list shows 412 errors and they're mostly "Cannot open source file" followed by a file name that I haven't heard of.
It also says the WindowsSDKDir property is not defined and the solution I found was to repair visual studio when I looked up this problem. I completed repairing visual studio and I have the C++ selected in the workloads.
Even when I select "Console App" during initial set up it'll end up giving me the same errors even though that is supposed to set up a basic environment for Hello World.
My code is simply just to print out hello world.
#include <iostream>
void output();
int main()
{
output();
}
void output()
{
std::cout << "Hello World!" << std::endl;
}
So I just uninstalled Visual Studio completely and then reinstalled it. I realized I could have just modified it using the installer, but basically after selecting the C++ workload I made sure every box was selected on the right hand side. I don't know if I needed it all but I just installed everything to be sure and it finally worked.

Error code = 0x80070002 in visual studio c++

I just installed visual studio, (not new to coding) and I keep getting an error that goes like "error: unable to open file C:user...main.obj Error code = 0x80070002"
an Image of the error
this error shows up whenever there is something wrong with my code like for example if i do:
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
everything runs normal, but if I make a mistake say:
#include <iostream>
int main()
{
std::cout std::cout << "Hello World!\n";
}
I get the error, it's so annoying I don't want to get that error every time there is something wrong with my code the error list bar is enough, what do I do ?
Could you please tell us what version of Visual Studio are you using?
If you are using vs2017 or later, I suggest you could try to use /DEBUG:FULL property in "Linker/Debugging/Generate Debug Info.
I suggest you could refer to the Doc:
When you specify /DEBUG with no additional options, the linker
defaults to /DEBUG:FULL for command line and make file builds, for
release builds in the Visual Studio IDE, and for both debug and
release builds in Visual Studio 2015 and earlier versions. Beginning
in Visual Studio 2017, the build system in the IDE defaults to
/DEBUG:FASTLINK when you specify the /DEBUG option for debug builds.
Other defaults are unchanged to maintain backward compatibility.
Rebuild the program in a different disk or reinstall the VS could be the final solution I think.

Simple Visual Studio console application does not start

I installed Visual Studio 2013 on my Windows 10 machine. To test the installation I wrote a simple program in C++:
#include <iostream>
using namespace std;
int main(){
cout << "Size of char is: " << sizeof(char);
cin.get();
return 0;
}
It's embarrassing to post such a simple code here but the problem is as follows. The build process runs without errors or warnings. But when I start the program via Debug-Button, Visual Studio freezes. I also tried starting the .exe in cmd. The result is a blinking cursor in an empty line with no further reaction from the console.
Can somebody tell me what's wrong? The Project Type in Visual Studio is empty visual c++ project.
Finally it works. As Peter M mentioned in his comment, the VS/Avast issue was the problem.

Visual Studio Compiler Error

I was making a simple DLL as a test in visual studio 2010.
Here is the code for SimpleCPP.cpp
#include iostream
#include "SimpleH.h"
namespace nmspace
{
void myclass::Crap()
{
std::cout << "Test." << std::endl;
}
}
Here is the code for the header file
#include <iostream>
namespace nmspace
{
class myclass
{
public:
static __declspec(dllexport) void Crap();
};
}
My problem is when I compile I get an error that says that visual studio can't find the file SimpleDLLd.dll. In closer inspection I see that when the program is compiling visual studio adds a d to the release files. For example when the DLL is supposed to be SimpleDLL.dll (The project name is SimpleDLL) visual studio adds a d and outputs SimpleDlld.dll. I tried doing the same thing in another project and it did the same thing. I then proceeded to Visual Studio 2013 and copy and pasted the contents of the cpp and header files into new files and surprisingly got the same exact result as Visual Studio 2010. How would I fix this error? Thank you for responding.
Check the name of the build target in your project file settings. The name of the resulting file should be in the
Linker->General->Output File
setting in the project which is usually $(OutDir)$(TargetName)$(TargetExt) by default.

fatal error C1083: Cannot open include file: 'iostream': No such file or directory

I've reinstalled Visual Studio 2010 Professional several times to try to get it to work.
I had to uninstall Visual Studio 2012 Professional because it wasn't compiling something we did in class.
I completely uninstalled everything including SQL Server..
I went to VC/include and the iostream header file is not there.
#include <iostream>
int main () {
cout << "hello";
system ("PAUSE");
return 0;
}
This is all I'm trying to do because nothing else is working.
It's really driving me crazy because I need to get it working so that I can do my project!!!
Every time I do; new project => empty project => add an item to source =>.cpp
I'm running windows 8.
It just says Error cannot open source file
Also, error cout identifier is undefined....
I'm wondering if I should do a system restore?
Or if I should just completely reinstall windows 8 from my recovery media?
One problem is that you did not include the namespace std.
This is what your code should look like:
#include <iostream>
using namespace std;
int main (void) {
cout << "hello" << endl;
system("pause");
return 0;
}
or you could have done something like this: std::cout << "Hello" << std::endl;
This may be a problem because you did not set your environment to C++. This is how you do it:
Go to Tools > Import and Export settings. If you cannot find it, just search for it in Quick Search
Then go to reset all settings.
Then simply select "Visual C++"
Restart.
That should do the trick. If it does not, you might consider re-installing Visual C++ itself. For VS 2012. If that does not work, then re-install the program.
if it is problem with visual studio 2012, install this update.