问题标签 [include]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
5 回答
47154 浏览

c++ - 如何在 Visual Studio 中包含子目录?

我必须包含许多头文件,它们位于不同的子目录中。在 Visual Studio(我使用的是 2005 版)中有没有办法设置一个包含路径,Visual Studio 也会在子目录中搜索头文件?

0 投票
2 回答
74682 浏览

include - 为 Makefile 中的标题添加目录

您好我想问您,如果有人知道如何在 Makefile 中为头文件添加目录以避免错误 *.h not found,我尝试过此选项但不起作用:

0 投票
3 回答
360 浏览

php - Refactoring a massive function into many files

I've been trying to refactor a "bit" of code that I'd previously developed. Basically, the project was my response to not knowing how to use XSLT effectively, so I developed an XML transformation system in PHP. The program reads through the tags of an XML file and does something along these lines to convert it to HTML:

That was all working great, except that I ended up with 26 branches to my switch, and that once switch block was over 1000 lines of code. Needless to say, it made maintenance slightly more difficult.

What I've done now is to pull the code of each branch out into its own file (named "a.php", "box.php", "ref.php" ...) and include that file each time:

Again, this works, but benchmarking it shows that it has slowed down processing times by 50%. I'm assuming that this is because there's now up to 4000 includes being done now.

What I was considering was to put the code for each template into a function, and if the function hasn't been declared then include the file, and then run the function - the only problem with that is that the existing code has been written in the scope of the original function, using $this, etc.

Given that this code is not run in real time (eg: it merely processes the XML into static HTML files which are stored - it's not done on the fly), do you have any advice for me here?

0 投票
4 回答
3076 浏览

c++ - 如何用#include 替换这个预处理器宏?

更新: 显然,您希望使用模板或基类而不是宏来执行此操作。不幸的是,由于各种原因,我不能使用模板或基类。


目前我正在使用宏在各种类上定义一堆字段和方法,如下所示:

FIELDS_AND_METHODS是一个使用字符串化和标记粘贴运算符的多行宏。

我想用下面的东西代替它

这里我#define类的名称(以前是宏的参数),FieldsNMethods.h文件包含原始宏的内容。但是,因为我是#include,所以在调试时我可以在运行时单步执行代码。

但是,我在“字符串化”和“标记粘贴”文件TYPE_NAME中的预处理器符号时遇到了麻烦FieldsNMethods.h

例如,我想在 中定义类的析构函数FieldsNMethods.h,所以这需要使用如下的值TYPE_NAME

但用TYPE_NAME它的价值代替。

我正在尝试的可能吗?我不能直接使用字符串化和标记粘贴运算符,因为我不在宏定义中。

0 投票
9 回答
61113 浏览

php - 如何格式化 PHP include() 绝对(而不是相对)路径?

在我的 PHP 网站的各个页面以及各种嵌套目录中,我想在相对于根目录的路径中包含一个特定文件。

我可以在这两个页面上输入什么命令...

...包括此页面:

这不起作用:

将其托管在 Windows 上的 IIS 中是否重要?

0 投票
2 回答
1892 浏览

xsd - 如何从具有常见包含的 xsd 生成多个类?

阿罗哈

我收到了一些不错的 xsd 文件,我想将它们转换为类(使用 xsd.exe)所有 xsd 都具有相同的包含,如下所示:

当我为每个 xsd 生成一个类时,这些文件中声明的类型对于每个原始 xsd 都是重复的。有什么简单的方法可以 1) 只生成包含的 xsd 中的类型一次和 2) 确保所有其他类都使用这些类型?

-Edoode

0 投票
13 回答
1705 浏览

c++ - 是否需要 C++ 中的#includes 的特定顺序是不良库/头文件设计的标志?

我使用了一些非常大规模的系统,从未见过所需的订单,但最近遇到了。STL 或 STD 库甚至 Boost 是否存在某些包含必须以特定顺序出现的情况?

0 投票
3 回答
1795 浏览

c++ - C++ 命名空间:交叉使用

考虑以下示例。它由两个头文件组成,声明了两个不同的命名空间:

第二个是

和一个单一的源文件,main.cpp

这样它就不会编译(尝试过 GCC 和 MSVC)。错误是a1未声明命名空间(Windows 上的 C2653)。如果您以main.cpp这种方式更改包含顺序:

您会收到一条对称错误消息,即a2未声明命名空间。

有什么问题?

0 投票
8 回答
301 浏览

php - 您更喜欢运行还是包含在一个 php 文件中?

你如何管理你的php代码?您更喜欢在一个 php 文件中运行还是包含更大的“原始代码”块?

编辑:事实上,我的代码非常讨厌,因为我不使用任何命名空间和类——只使用函数和包括在内。我会查课的^^。

0 投票
3 回答
529 浏览

php - PHP 的绝对路径包括

好的,我在这个星期五的工作中设置了一个表,其中包含来自名为 values.php 的单独文件的数据。当我这样写时,div 变成空白。我想我的“包含”写错了,绝对路径不起作用吗?

哦,提前感谢您提供的任何帮助。帮助过我的人是最伟大的。我感觉很糟糕,因为有时两个人回答了这个问题,而我不能给两个人都投绿票。