Код: Выделить всё
x86_64-w64-mingw32-gcc -std=c++23 -fmodules-ts -x c++-system-header -c cstdint variant exception
x86_64-w64-mingw32-gcc -std=c++23 -fmodules-ts -lstdc++ -x c++ -c error.cppm -o error.o
x86_64-w64-mingw32-gcc -std=c++23 -fmodules-ts error.o main.cpp -lstdc++ -static-libstdc++ -o test.exe
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccztFNJq.o:main.cpp:(.text+0x0): multiple definition of `Crash@Error::~Crash()'; error.o:error.cppm:(.text$_ZNW5Error5CrashD1Ev[_ZNW5Error5CrashD1Ev]+0x0): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccztFNJq.o:main.cpp:(.text+0x2e): multiple definition of `Crash@Error::~Crash()'; error.o:error.cppm:(.text$_ZNW5Error5CrashD0Ev[_ZNW5Error5CrashD0Ev]+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
Исключение было создано согласно этот файл:
error.cppm
Код: Выделить всё
export module Error;
import ;
import ;
export enum class ErrorCode: uint8_t {
INVALID,
PROBLEM1,
PROBLEM2,
};
export class Crash: public std::exception {
public:
Crash(ErrorCode crashCode) noexcept: code(crashCode) { }
private:
ErrorCode code;
};
main.cpp
Код: Выделить всё
import Error;
int main() {
throw Crash(ErrorCode::PROBLEM1);
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... gcc-14-2-0
Мобильная версия