I'm trying to compile a minimal viable example, which contains the following file:
main.cpp:
#include <expected>
#include <iostream>
std::expected<int, std::string> try_func() {
return 100;
}
int main() {
try_func();
return 0;
}
I'm additionally using premake5 to create my build scripts. Here is my build script: premake5.lua:
workspace "interop"
configurations { "Release" }
architecture "x64"
startproject "test_project"
project "test_project"
kind "ConsoleApp"
language "C++"
cppdialect "C++latest"
location "test_project"
targetdir ("bin/%{cfg.buildcfg}/%{prj.name}")
objdir ("bin-int/%{cfg.buildcfg}/%{prj.name}")
files
{
"test_project/main.cpp"
}
The project is structured as follows:
interop
test_project
main.cpp
premake5.lua
Compiling on Windows
To compile on Windows I just run:
premake5 vs2022
And then I build the generated VS projects, everything works correctly.
Compiling on Linux
To compile on Linux I run:
premake5 gmake
make
My CXX
is GCC, and I've updated to the latest version via -Syu. Running the above command produces the following warnings:
'expected' in namespace 'std' does not name a template type
Note that I do get the following message:
'std::expected' is only available from C++23 onwards
I'm however puzzled as to why I'm not supposedly compiling with C++23 when I'm using the latest
flag. Any help is greatly appreciated.