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

Standard library issues #16

Closed
sagamusix opened this issue Jul 18, 2017 · 12 comments
Closed

Standard library issues #16

sagamusix opened this issue Jul 18, 2017 · 12 comments

Comments

@sagamusix
Copy link

@sagamusix sagamusix commented Jul 18, 2017

I am using the pre-built djgpp package (gcc 7.1.0, Linux Mint 32-bit).
As far as I can see, there is a complete, up-to-date standard library coming with it, just as I expected, but somehow I cannot access most of it.

test.cpp:

#include <string>
int main()
{
std::string s;
std::wstring w;
return 0;
}

Result of g++ test.cpp:

test.cpp: In function 'int main()':
test.cpp:5:6: error: 'wstring' is not a member of 'std'
 std::wstring w;
      ^~~~~~~
test.cpp:5:6: note: suggested alternative: 'isprint'
 std::wstring w;
      ^~~~~~~
      isprint

Running cc1plus -v shows that, as far as I can tell, all relevant include paths from the downloaded package are listed.

Is this a known issue? What am I doing wrong?

@lpsantil
Copy link

@lpsantil lpsantil commented Jul 18, 2017

Are you using g++ instead of i586-pc-msdosdjgpp-g++?

@sagamusix
Copy link
Author

@sagamusix sagamusix commented Jul 18, 2017

I was following the examples in the readme, i.e. I tried both the export variant and the source BASE_DIR/setenv, and then used g++. After doing so, g++ does indeed point to djgpp rather than the system-provided g++, but i586-pc-msdosdjgpp-g++ is not found.

@lpsantil
Copy link

@lpsantil lpsantil commented Jul 19, 2017

What does g++ -v return?

What does i586-pc-msdosdjgpp-g++ return?

You should have both in your path from build-djgpp.

What is BASE_DIR?

What shell are you using?

What does env return?

@sagamusix
Copy link
Author

@sagamusix sagamusix commented Jul 19, 2017

Since I am using the pre-compiled package (not enough space in my virtual machine to build my own), there was no build-djgpp involved.

If I just run source BASE_DIR/setenv as described in the manual, g++ still refers to the system-provided g++. So I try

export PATH=BASE_DIR/i586-pc-msdosdjgpp/bin/:$PATH
export GCC_EXEC_PREFIX=BASE_DIR/lib/gcc/

With BASE_DIR obviously replaced as instructed in the manual.

Now I get:

> g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/jojo/djgpp/lib/gcc/../../libexec/gcc/i586-pc-msdosdjgpp/7.1.0/lto-wrapper
Target: i586-pc-msdosdjgpp
Configured with: ../gnu/gcc-7.10/configure --target=i586-pc-msdosdjgpp --program-prefix=i586-pc-msdosdjgpp- --prefix=/usr/local/djgpp --disable-nls --disable-plugin --disable-lto --enable-lto --enable-libquadmath-support --with-gmp=/home/vagrant/build-djgpp/build/djcross-gcc-7.1.0/tmpinst --with-mpfr=/home/vagrant/build-djgpp/build/djcross-gcc-7.1.0/tmpinst --with-mpc=/home/vagrant/build-djgpp/build/djcross-gcc-7.1.0/tmpinst --enable-version-specific-runtime-libs --enable-languages=c,c++
Thread model: single
gcc version 7.1.0 (GCC)

> i586-pc-msdosdjgpp-g++
i586-pc-msdosdjgpp-g++: command not found

What shell are you using?

I'm using bash.

@lpsantil
Copy link

@lpsantil lpsantil commented Jul 19, 2017

Maybe it's a doc bug, but I usually set my export PATH=$BASE_DIR/bin:$PATH and use the full name of the compiler and then set CC in my Makefiles or ./configure script. I don't recall having to use GCC_EXEC_PREFIX and $BASE_DIR/setenv script also sets the var DJDIR which is a djgpp-ism.

My guess is that calling the compiler via g++ and possibly export'ing the wrong PATH causes g++ to use cc1plus from the system which gets confused about -I paths and uses /usr/include instead.

@sagamusix
Copy link
Author

@sagamusix sagamusix commented Jul 19, 2017

I tried export PATH=$BASE_DIR/bin:$PATH followed by i586-pc-msdosdjgpp-g++ test.cpp but the compilation error remains: string is recognized, wstring is not. Really strange because even running i586-pc-msdosdjgpp-cpp test.cpp shows that the correct include files appear to be preprocssed. In the preprocessed output, I don't see a single trance of wstring. std::u32string and std::u16string are available though, so my next guess would be that for some reason, std::wstring is missing entirely in djgpp? I also tried using std::round which is missing even when specifying -std=c++11, certainly all of these standard library functions cannot be missing while all the other recent stuff is in there? My hope is still that this is a user error and not a problem with the precompiled package or djgpp itself. :)

@lpsantil
Copy link

@lpsantil lpsantil commented Jul 19, 2017

Try adding #include <wchar.h> at the top of the source. Maybe you're hitting this delta [0] of djgpp's headers/c++ lib?

[0] https://www.thecodingforums.com/threads/wstring-wcout-in-gcc-under-djgpp-cygwin.290393/

@sagamusix
Copy link
Author

@sagamusix sagamusix commented Jul 19, 2017

Sadly that also doesn't solve the problem, std::wstring is still not available. Given that std::round is also not available (despite specifying -std=c++11, I think something more profound is going wrong.

@andrewwutw
Copy link
Owner

@andrewwutw andrewwutw commented Jul 20, 2017

It seems the official DOS version of DJGPP (http://www.delorie.com/djgpp/) doesn't support wstring neither. Maybe it is a bug or limitation of DJGPP?

@sagamusix
Copy link
Author

@sagamusix sagamusix commented Jul 20, 2017

I feared this might be the issue (and it seems rather weird given that u16string and u32string are supported). I guess I'll have to find out what exactly from the standard library is available and what isn't...

@andrewwutw
Copy link
Owner

@andrewwutw andrewwutw commented Jul 22, 2017

@sagamusix I asked this question on DJGPP mailing list, the answer is that DJGPP doesn't support wide character / multi byte string.

So, I think unless someone implements these functions in DJGPP source code, this problem can't be fixed. 😢

See:
http://www.delorie.com/djgpp/mail-archives/browse.cgi?p=djgpp/2017/07/21/08:57:06
http://www.delorie.com/djgpp/mail-archives/browse.cgi?p=djgpp/2017/07/21/18:25:23

@andrewwutw andrewwutw closed this Jul 22, 2017
@sagamusix
Copy link
Author

@sagamusix sagamusix commented Jul 23, 2017

Thanks for taking the time to report it on the mailing list. :) Too bad that nothing can be done about it right now, but also good to know that it was not a problem with the usage of the precompiled package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants