Is there a way to get the ROS_DISTRO in c++, cz I want to run specific C++ code when ros_distro is melodic, and else if noetic then this code. Ubuntu: 20.04 Thank You.
In C++ you can simply use getenv()
to grab environmental variables.
import <iostream>
int main(){
std::string distro = getenv("ROS_DISTRO");
std::cout << "Got distro: " << distro << std::endl;
}