我应该把这个 .h 文件放在哪里,或者如何在 TextMate 中正确设置我的路径?

发布于 2024-11-30 23:55:58 字数 827 浏览 2 评论 0原文

我刚刚通过在线提供的斯坦福 CS 106B 讲座开始接触 C++。这些作业让学生使用一些可以在线下载的自定义库,尽管安装说明已经消失。

虽然我可以使用预构建的空白项目(其中包括设置的相关文件和源树)在 Xcode 中完成作业,但我手头还有 TextMate,并且我想尝试用它进行编码,因为我喜欢使用它大量用于 LaTeX 编码。到目前为止,一切都很好。

我尝试运行的第一个程序(一个非常简单的十行程序)在第一行包含一个 # include "genlib.h" 。我有 genlib.h 文件,但似乎无法使以下任一功能正常工作:

  1. 在 TextMate 中添加相关文件的路径:当我尝试将路径添加到我的桌面上文件所在的文件夹 (/previouspathinthelist:/Users/me/Desktop/C++\libraries) 我收到错误:/Users/me/Documents/由 小码哥发布于programs/powertab.cpp:9:20:错误:genlib.h:没有这样的文件或目录即使该文件就在那里! (也许这里应该注意一下,要导入的文件和程序文件位于两个不同的文件夹中)。
  2. 将文件添加到其他路径之一:我无法在终端中使用 mv 将文件移动到 usr/binusr/sbin等等,因为它说我没有适当的权限。

我在“文档”中设置文件夹路径时是否做错了什么?由于路径直接来自取景器中的获取信息,因此没有任何拼写错误或任何错误。我知道这是一个编程论坛,而不是 TextMate 支持论坛,但我认为了解人们通常将此类文件放在系统上的位置会很有帮助。

I'm just getting my feet wet in C++ using the Stanford CS 106B lectures available online. The assignments have the students use some custom libraries which are available for download online, although the installation instructions are gone.

While I can do the assignments in Xcode using a pre-built blank project which includes the relevant files and source trees set up, I also have TextMate on hand and thought I'd like to try coding with it, since I liked using it a lot for coding LaTeX. So far so good.

The first program I'm trying to run (a very simple ten-line program) contains an # include "genlib.h" in the first line. I have the genlib.h file, but can't seem to get either of the following to work:

  1. Add the path to the relevant file in TextMate: When I try to add the path to the folder on my desktop (/previouspathinthelist:/Users/me/Desktop/C++\ libraries) where the file lives I get an error: /Users/me/Documents/c++ programs/powertab.cpp:9:20: error: genlib.h: No such file or directory even though the file is right there! (Maybe I should note here that the file to be imported and the program file are in two different folders).
  2. Add the file to one of the other paths: I can't move the files using mv in terminal to usr/bin, usr/sbin, etc. because it says I don't have the proper permissions.

Is there something I'm doing wrong in setting my path to my folder in Documents? There aren't any spelling mistakes or anything since the path came straight from get info in the finder. I know this is a programming forum and not a TextMate support forum, but I thought it'd be good to know where people generally put these kinds of files on their systems.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

东北女汉子 2024-12-07 23:55:58

只需将该文件放在与其他源文件相同的目录中即可。

#include "filename"

首先搜索源目录,而

#include <filename>

只搜索包含文件路径。

/previouspathinthelist:/Users/me/Desktop/C++\libraries 不起作用的原因可能与文件名中的空格有关。反斜杠很可能不是引用您正在使用的工具中的空格的正确方法。许多来自 C/unix 传统的工具在处理包含空格的路径名时表现得相当糟糕(尽管 Unix 内核本身没有这样的问题);通常,您会发现没有单一数量的引用可以同时满足使用某些设置的所有工具和子系统。当您进行开发时,最好完全避免文件名中出现空格。

Just put the file in the same directory as your other source files.

#include "filename"

searches the source directory first, whereas

#include <filename>

only searches the include file path.

The reason why /previouspathinthelist:/Users/me/Desktop/C++\ libraries doesn't work probably has to do with the space in the file name. It is quite possible that a backslash is not the right way to quote the space in the tool you're using. Many tools from the C/unix tradition deal rather badly with pathnames that contain space (even though the Unix kernel itself has no such problem); often you'll find that there is no single amount of quoting that will simultaneously satisfy all the tools and subsystems that use some setting. Better to avoid spaces in filenames entirely when you're doing development.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文