fengwang / Stable-Diffusion-NCNN

Stable Diffusion inference in pure C++
60 stars 5 forks source link

Can't compile. Invalid: " auto [cond, uncond] = prompt_solver( positive_prompt, negative_prompt );" #2

Closed Dingo64 closed 1 year ago

Dingo64 commented 1 year ago

I am trying to compile under Windows. I am using "-std=c++17" because that's the newest that seems to work with MinGW.

I am getting this error:

stable_diffusion.hpp: In function 'void stable_diffusion(std::__cxx11::string, std::__cxx11::string, int, int, std::__cxx11::string)':
stable_diffusion.hpp:819:10: error: expected unqualified-id before '[' token
     auto [cond, uncond] = prompt_solver( positive_prompt, negative_prompt );
fengwang commented 1 year ago

Structured binding is introduced since c++17. Do you mind sharing the gcc version and the compile command?

Dingo64 commented 1 year ago

g++ (MinGW.org GCC-6.3.0-1) 6.3.0

set PATH=C:\mingw\bin;%PATH%
set CPATH=K:\ncnn_stable\ncnn
g++ -I "K:/ncnn_stable/" -I "K:/ncnn_stable/ncnn/" -o test test.cpp -funsafe-math-optimizations -Ofast -flto=auto  -funroll-all-loops -pipe -march=native -std=c++17 -Wall -Wextra  -lstdc++ -pthread -Wl,--gc-sections -flto -fopt-info-vec-optimized
Dingo64 commented 1 year ago

This is the newest MinGW for Windows but it comes with GCC 6.3 which is old. I found out there is MinGW-w64 which comes with newer GCC and in MinGW-w64 this error is gone, so I am closing this issue.

MinGW-w64: https://winlibs.com/