我有一个getcwd()用于获取当前工作目录的构建系统工具。这很好,只是有时人们的路径中有空格,而构建系统不支持这一点。你会认为你可以只做一个符号链接:
ln -s "Directory With Spaces" DirectoryWithoutSpaces
然后快乐起来。但对我来说不幸的是,getcwd()解决了所有的符号链接。我尝试使用getenv("PWD"),但它指向的路径与我返回的路径不同getcwd()。我认为,我责怪make -C没有更新环境变量。现在,getcwd()给我一条这样的路径:
/Users/carl/Directory With Spaces/Some/Other/Directories
并getenv("PWD")给我:
/Users/carl/DirectoryWithoutSpaces
那么 - 是否有任何类似getcwd()的功能不能解决符号链接?
编辑:
我变了
make -C Some/Other/Directories
到
cd Some/Other/Directories ; make
然后getenv("PWD")工作..如果没有其他解决方案,我可以使用它。