R.....y
R.....y
#programowanie #cpp #naukaprogramowania
Chciałem odpalić c++20 i potestować jak to wygląda bo jestem ciekawy
mój protip jak ktoś chce to robić: róbcie to pod wodą żeby nikt nie widział płaczu, ani nie słyszał krzyku
próbuje narazie skompilować moduł clangiem, i kiepsko mi to idzie, chętnie się dowiem jakie flagi powinienem użyć
  • Najlepsze
  • Wszystkie komentarze
Passer93
@RedveKoronny: nie kompiluj ręcznie bo to mordęga xD Od tego masz przecież IDE. Jak używasz VS Code to zainstaluj wtyczke pod CMAKE i bzikaj
Passer93
@RedveKoronny: msvc 19.24 wspiera już zdecydowana większość c++ 20 w tym moduły
dupasmoka
-std=c++2a lub -std=c++20 w zaleznosc jaka wersje llvm+clang masz. Lista wspieranych feature'ow tutaj https://clang.llvm.org/cxx_status.html
R.....y
R.....y
@dupasmoka: jak kompiluje modół przez:
clang++-11 -fmodules -std=c++20 helloworld.cpp -o helloworld
dostaje linker command failed with exit code 1
undefined reference to 'main'
dupasmoka
moze pokaz kod bedzie latwiej
R.....y
R.....y
@dupasmoka: https://en.cppreference.com/w/cpp/language/modules to jest kod który próbuje zmusić do działania
dupasmoka
@RedveKoronny: no to masz dwa pliki helloworld.cpp i main.cpp wiesz musisz oba skompilowac i zlinkowac w jednym kroku poprzez clang++ -fmodules -std=c++20 helloworld.cpp main.cpp -omojprogram
albo osobno skompilowac kazdy z nich

clang++ -c -fmodules -std=c++20 helloworld.cpp
clang++ -c -fmodules -std=c++20 main.cpp
R.....y
R.....y
@dupasmoka: czego bym nie próbował,
fatal error: module 'helloworld' not found
dupasmoka
@RedveKoronny:
Now, let’s compile it. There are two steps in compiling this program:
Compile the module into .pcm , which stands for Pre-compiled Module
Compile main.cpp with the .pcm file
In Clang 10, we have to specify the flag -std=c++2a with other flags. Refer to the Clang Modules page for detailed explanation.
$ clang++ -std=c++2a -c helloworld.cpp -Xclang -emit-module-interface
R.....y
R.....y
@dupasmoka: efektem drugiej komendy jest 20 errorów pokroju:
std::overflowerror:overflowerror from module helloworld. is not present in definition of std::overflow_error
dupasmoka
u mnie zadzialalo to

$ clang++ -std=c++2a -stdlib=libc++ -fimplicit-modules -fimplicit-module-maps -c helloworld.cpp -Xclang -emit-module-interface -o helloworld.pcm
$ clang++ -std=c++2a -stdlib=libc++ -fimplicit-modules -fimplicit-module-maps -fprebuilt-module-path=. main.cpp helloworld.cpp
$ ./a.out
Hello Module! Data is 123
dupasmoka
@RedveKoronny:

[nix-shell:/tmp/cppmodules]$ clang++ -std=c++2a -stdlib=libc++ -fimplicit-modules -fimplicit-module-maps -c helloworld.cpp -Xclang -emit-module-interface -o helloworld.pcm
clang-11: warning: argument unused during compilation: '-stdlib=libc++' [-Wunused-command-line-argument]
JakTamCoTam
@RedveKoronny: odpal sobie visual studio, wystarczy że zaznaczysz jednego checkboxa i już masz. Programowanie w c++ na Linuxie to masochizm, ale niestety wiele firm woli oszczędzać i trzeba ...
R.....y
R.....y
@dupasmoka: twoja wersja juz ogarnia moduły, ale nie ogarnia np. featurow z algorithm jak std::shift_left, widze ze narazie duzo jest z tym pieprzenia
R.....y
R.....y
@JakTamCoTam: używałem kiedys więcej wersji community, ale nie specjalnie widziałem tam taką opcje, chyba ze cos sie zmieniło od ostatniego razu
JakTamCoTam
@RedveKoronny: a którą? Od Visual studio 2017 na bank jest. W 2013/2015 już nie pamiętam.
R.....y
R.....y
@JakTamCoTam: 2019 nie bardzo ogarniała c++ 20, przynajmniej jak używałem go jakos w grudniu/listopadzie
R.....y
R.....y
@JakTamCoTam: podobno dopiero vs 2022 który ogłoszą w lato ma to ogarniac
dupasmoka
nie ogarnia np. featurow z algorithm jak std::shift_left


@RedveKoronny: a to juz zalezy od implementacji headera/modulu algorithm w twojej implementacji bilbioteki standardowej
dupasmoka