Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: no member named 'cout' in namespace 'std' #5

Open
JayFoxRox opened this issue Apr 10, 2021 · 1 comment · May be fixed by #7
Open

error: no member named 'cout' in namespace 'std' #5

JayFoxRox opened this issue Apr 10, 2021 · 1 comment · May be fixed by #7

Comments

@JayFoxRox
Copy link
Member

While getting rid of my old GitHub notifications I noticed that I had an issue with lack of std::cout in the past, which became a problem while porting some projects.

This issue is basically a bug report for the workaround seen here: https://github.com/JayFoxRox/nxdk/tree/2c850026a565eea0435cb14370b0a9d8864cdd33/usr/share/nxdk/samples/ozz-animation
(I also briefly looked at the independent issue with #include <atomic> / std::atomic_int allocation_count_ / allocation_count_.store(0) / allocation_count_.load(), which appears to have been a problem back then, but it seems to be compile fine on XboxDev/nxdk@72485f4 / c594e97. I did not try running it though)

#include <hal/video.h>
#include <windows.h>

#include <iostream>

int main(void) {
  XVideoSetMode(640, 480, 32, REFRESH_DEFAULT);

  std::cout << "Hello!" << std::endl; // Does not compile: "error: no member named 'cout' in namespace 'std'"
  std::cerr << "Hello!" << std::endl; // Compiles

  while (true) {
    Sleep(2000);
  }

  return 0;
}

Not sure if we had discussed this in the past or if an issue already exists.

@JayFoxRox
Copy link
Member Author

JayFoxRox commented May 8, 2021

This will be caused by this:

#define _LIBCPP_HAS_NO_STDIN
#define _LIBCPP_HAS_NO_STDOUT

which controls this:

#ifndef _LIBCPP_HAS_NO_STDIN
extern _LIBCPP_FUNC_VIS istream cin;
extern _LIBCPP_FUNC_VIS wistream wcin;
#endif
#ifndef _LIBCPP_HAS_NO_STDOUT
extern _LIBCPP_FUNC_VIS ostream cout;
extern _LIBCPP_FUNC_VIS wostream wcout;
#endif
extern _LIBCPP_FUNC_VIS ostream cerr;
extern _LIBCPP_FUNC_VIS wostream wcerr;
extern _LIBCPP_FUNC_VIS ostream clog;
extern _LIBCPP_FUNC_VIS wostream wclog;

I think that disabling cout is pointless, if there are also cerr and clog, which also go nowhere.
The nxdk libc also provides stdout (and stdin), so I don't think there's a good reason to disable it in C++.

With stdout / cout we can probably just ignore it. For stdin / cin we'll need a better solution probably.

nxdk will probably need a way to hook up virtual file descriptors for pdclib to handle this properly.
I assume it's possible to register a virtual filesystem through the kernel?
If that works, we could optionally connect stdout / stdin to debuggers via network (or similar).

Edit: Here are some links in how this works on Windows:

@JayFoxRox JayFoxRox linked a pull request May 9, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant