我正在使用 ubuntu 14.04。我在程序的 main() 顶部添加了以下代码,但运行它时没有打印任何内容。
char const* masteruri = getenv("ROS_MASTER_URI");
if (masteruri!=NULL){
printf ("The current masteruri is: %s",masteruri);
}
char const* rosdis = getenv("ROS_DISTRO");
if (rosdis!=NULL){
printf ("\n The current rosdis is: %s",rosdis);
}
但是另一个程序中的相同代码给出了预期的结果
The current masteruri is: http://localhost:11311
The current rosdis is: indigo
我已经包含了 stdlib.h 并在 etc/profile.d 中导出了变量