简体   繁体   English

在没有IDE的情况下编译单个文件,C ++

[英]Compiling a single file without an IDE, c++

I´m working on a unit tester for c++, mostly for practice, but I´m stuck. 我正在研究c ++的单元测试器,主要是为了练习,但是我被困住了。

The way I want it to work is as follows: 我希望它的工作方式如下:

  1. It reads all class and function names from all .hpp files within a defined test folder and its sub-folders. 它从定义的测试文件夹及其子文件夹中的所有.hpp文件中读取所有类和函数的名称。 These have assertions that are linked to a logger that outputs HTML files with the test results. 这些具有断言,这些断言链接到记录器,该记录器输出带有测试结果的HTML文件。
  2. It creates a single .hpp or .cpp file that creates one instance of every test class and runs every function in it. 它创建一个.hpp或.cpp文件,该文件为每个测试类创建一个实例并运行其中的每个函数。
  3. It compiles the .hpp/.cpp file created in step 2. 它编译在步骤2中创建的.hpp / .cpp文件。
  4. It runs the output of step 3. 它运行步骤3的输出。

I have 1. and 2. down but I´m having trouble compiling the .hpp file I created. 我有1.和2.下,但在编译创建的.hpp文件时遇到问题。 I initially wanted to compile using a simple call to cl.exe but that is proving to be more problematic than I originally anticipated. 我最初想使用对cl.exe的简单调用进行编译,但是事实证明,这比我最初预期的要麻烦得多。

Do any of you know of a good/simple way of compiling a single file? 你们中有人知道编译单个文件的好/简单方法吗? I have done some research on make/nmake but I can´t figure out how to accomplish this with them. 我已经对make / nmake进行了一些研究,但是我不知道如何使用它们来完成此工作。

Also, if this method of doing unit tests is completely stupid, please let me know. 另外,如果这种进行单元测试的方法完全是愚蠢的,请告诉我。

Some info: I´m using Windows 7 64-bit and Visual Studio 2010 一些信息:我正在使用Windows 7 64位和Visual Studio 2010

Assuming the generated something.cpp file contains #include "something.hpp" , then it should just be a case of cl something.cpp and you get a something.exe , which you can run in some suitable way. 假设生成的something.cpp文件包含#include "something.hpp" ,则应该是cl something.cpp一种情况,并且您会得到something.exe ,可以通过某种合适的方式运行它。

"Calling every funciton on an object" seems a little strange - how do you know whether the result is correct? “调用对象的每个函数”似乎有点奇怪-您如何知道结果是否正确? If we have a complex object, it may require more than creation to support calling all functions. 如果我们有一个复杂的对象,它可能需要更多的内容来支持调用所有函数。 What parameters are you passing in to each function? 您要向每个函数传递哪些参数? How do you know what it should return? 您怎么知道它应该返回什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM