[英]Changing include/object files mid program C++
Me and some buddies are trying to construct a game engine that can run multiple games in c++. 我和一些伙伴正在尝试构建一个可以在c ++中运行多个游戏的游戏引擎。 The games are similar enough that they all share similar mechanics and interfaces that I want to make some files that apply to each game. 这些游戏非常相似,以至于它们都共享相似的机制和界面,因此我想制作一些适用于每个游戏的文件。 Many of the source files will be the same like our GUI's or Game Engine files. 许多源文件将与我们的GUI或Game Engine文件相同。 However, some files that deal with individual game mechanics will change from game to game. 但是,某些处理各个游戏机制的文件会因游戏而异。 If this expands to a large library, I don't want to simply include every file from every library to play one game. 如果扩展到一个大型库,我不想简单地包含每个库中的每个文件来玩一个游戏。 I also don't want to have a duplicate of GUI and game engine files in every folder in the library. 我也不想在库中的每个文件夹中都有GUI和游戏引擎文件的副本。
I am currently thinking about the idea of a launcher that will change the #include tags to match the choice made by the launcher, although this may require recompiling. 我目前正在考虑一个启动程序的想法,该程序将更改#include标签以匹配该启动程序所做的选择,尽管这可能需要重新编译。 Is there a way to make this/ is it a good technique, or is their a better way. 有没有办法使这个/是一种好技术,还是他们更好的方法? (keep in mind i'd prefer int main to remain in game engine/ a shared file, and not make a main for each game) (请记住,我宁愿将int main保留在游戏引擎/共享文件中,而不是为每个游戏制作main)
Summarizing your requirements: 总结您的要求:
If this is correct, here some thoughts to help you further: 如果正确,这里有一些想法可以进一步帮助您:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.