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

Compilation error #3

Closed
mcc-devel opened this issue Dec 9, 2020 · 4 comments
Closed

Compilation error #3

mcc-devel opened this issue Dec 9, 2020 · 4 comments

Comments

@mcc-devel
Copy link

While compiling with your complier, I met the following error:

C:\ptrs>C:\gcc11\gcc\bin\g++ ptrs.cpp
In file included from c:\gcc11\gcc\lib\gcc\x86_64-w64-mingw32\11\include\c++\bits\postypes.h:40,
                 from c:\gcc11\gcc\lib\gcc\x86_64-w64-mingw32\11\include\c++\iosfwd:40,
                 from c:\gcc11\gcc\lib\gcc\x86_64-w64-mingw32\11\include\c++\ios:38,
                 from c:\gcc11\gcc\lib\gcc\x86_64-w64-mingw32\11\include\c++\ostream:38,
                 from c:\gcc11\gcc\lib\gcc\x86_64-w64-mingw32\11\include\c++\iostream:39,
                 from demo:1,
                 from ptrs.cpp:1:
c:\gcc11\gcc\lib\gcc\x86_64-w64-mingw32\11\include\c++\cwchar:44:10: fatal error: wchar.h: No such file or directory 
   44 | #include <wchar.h>
      |          ^~~~~~~~~
compilation terminated.

I used the following files:
demo:

#pragma once
#include <iostream>
#include <string>
using std::cout;
using std::endl;
using std::string;

template <typename T>
class demo {
private:
    T var;
    string name;
    string scope;
    static string ato = "auto_ptr";
    static string uniq = "unique_ptr";
    static string shr = "shared_ptr";
public:
    demo(T val = 0, string n = "NULL", string sc = "main()", string pt = demo::ato) {
        var = val;
        name = n;
        scope = sc;
        cout << "Object " << name << " with value of " << var << " in scope " << scope << " created using " << pt << "." << endl;
    }
    
    ~demo() {
        cout << "Object " << name << " with value of " << var << " in scope " << scope << " destroyed by " << pt << "." << endl;
    }

    void setnm(string nm) {name = nm;}
    void setv(T v) {var = v;}
}

ptrs.cpp:

#include "demo"
#include <iostream>
#include <memory>
using namespace std;

int main() {
    auto_ptr p1 = new demo<unsigned short>(1, "p1");
    unique_ptr p2 = new demo<unsigned short>(2, "p2", , demo<unsigned short>::uniq);
    shared_ptr p3 = new demo<unsigned short>(3, "p3", , demo<unsigned short>::shr);
    auto_ptr p11 = p1;
    p11 -> setnm("p11");
    //unique_ptr p22 = p2;     will cause err at compile time
    //p22 -> setnm("p22");
    shared_ptr p33 = p3;
    p33 -> setnm("p33");
    return 0;
}
@zero9178
Copy link
Owner

What's the output of g++ -v ptrs.cpp? wchar.h is part of MinGW so it should be in the x86_64-w64-mingw32/include directory

@mcc-devel
Copy link
Author

Using built-in specs.
COLLECT_GCC=C:\gcc11\gcc\bin\g++
COLLECT_LTO_WRAPPER=c:/gcc11/gcc/bin/../libexec/gcc/x86_64-w64-mingw32/11/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../configure --target=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --disable-bootstrap --enable-libstdcxx-debug --with-tune=znver1 --prefix=/mnt/c/GCC --with-sysroot=/mnt/c/GCC-Build/NewestLinux --with-build-sysroot=/mnt/c/GCC-Build/NewestLinux --disable-libstdcxx-pch --disable-multilib --enable-libgomp --with-cross-host --with-libiconv-prefix=/mnt/c/GCC-Build/NewestLinux/Libraries --disable-libstdcxx-verbose --enable-languages=c,c++,fortran,lto,objc,obj-c++ --disable-nls --disable-win32-registry --enable-shared --with-gnu-as --with-gnu-ld --enable-threads=posix --program-suffix=-11 --enable-version-specific-runtime-libs --with-gcc-major-version-only --enable-__cxa_atexit --enable-plugin --program-prefix=
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.0.0 20201110 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=znver1' '-march=x86-64' '-dumpdir' 'a-'
 c:/gcc11/gcc/bin/../libexec/gcc/x86_64-w64-mingw32/11/cc1plus.exe -quiet -v -iprefix c:\gcc11\gcc\bin\../lib/gcc/x86_64-w64-mingw32/11/ -D_REENTRANT ptrs.cpp -quiet -dumpdir a- -dumpbase ptrs.cpp -dumpbase-ext .cpp -mtune=znver1 -march=x86-64 -version -o C:\Users\jett\AppData\Local\Temp\ccUipPZT.s
GNU C++17 (GCC) version 11.0.0 20201110 (experimental) (x86_64-w64-mingw32)
        compiled by GNU C version 10.2.1 20200804, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring nonexistent directory "c:\gcc11\gcc\bin\../lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/include"
ignoring duplicate directory "c:/gcc11/gcc/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11/include/c++"
ignoring duplicate directory "c:/gcc11/gcc/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11/include/c++/x86_64-w64-mingw32"
ignoring duplicate directory "c:/gcc11/gcc/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11/include/c++/backward"
ignoring duplicate directory "c:/gcc11/gcc/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11/include"
ignoring nonexistent directory "/mnt/c/GCC-Build/NewestLinux/mnt/c/GCC/lib/gcc/x86_64-w64-mingw32/11/../../../../include"
ignoring duplicate directory "c:/gcc11/gcc/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11/include-fixed"
ignoring nonexistent directory "c:/gcc11/gcc/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "/mnt/c/GCC-Build/NewestLinux/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 c:\gcc11\gcc\bin\../lib/gcc/x86_64-w64-mingw32/11/include/c++
 c:\gcc11\gcc\bin\../lib/gcc/x86_64-w64-mingw32/11/include/c++/x86_64-w64-mingw32
 c:\gcc11\gcc\bin\../lib/gcc/x86_64-w64-mingw32/11/include/c++/backward
 c:\gcc11\gcc\bin\../lib/gcc/x86_64-w64-mingw32/11/include
 c:\gcc11\gcc\bin\../lib/gcc/x86_64-w64-mingw32/11/include-fixed
End of search list.
GNU C++17 (GCC) version 11.0.0 20201110 (experimental) (x86_64-w64-mingw32)
        compiled by GNU C version 10.2.1 20200804, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 549845ecba30700c7d4bcb9917032570
In file included from c:\gcc11\gcc\lib\gcc\x86_64-w64-mingw32\11\include\c++\bits\postypes.h:40,
                 from c:\gcc11\gcc\lib\gcc\x86_64-w64-mingw32\11\include\c++\iosfwd:40,
                 from c:\gcc11\gcc\lib\gcc\x86_64-w64-mingw32\11\include\c++\ios:38,
                 from c:\gcc11\gcc\lib\gcc\x86_64-w64-mingw32\11\include\c++\ostream:38,
                 from c:\gcc11\gcc\lib\gcc\x86_64-w64-mingw32\11\include\c++\iostream:39,
                 from demo:2,
                 from ptrs.cpp:1:
c:\gcc11\gcc\lib\gcc\x86_64-w64-mingw32\11\include\c++\cwchar:44:10: fatal error: wchar.h: No such file or directory
   44 | #include <wchar.h>
      |          ^~~~~~~~~
compilation terminated.

@zero9178
Copy link
Owner

ignoring nonexistent directory "c:/gcc11/gcc/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/include"
Could it be that for some reason the directory C:\gcc11\gcc\x86_64-w64-mingw32\include does not exist on your machine?

@mcc-devel
Copy link
Author

Ah, yes, sorry about that.

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

No branches or pull requests

2 participants