generating .obj files out of header files
-
hi there i have a project in visual c++ 7, with a main.cpp file, and 5 header files used by the main file. how do i get the compiler to generate a .obj file for each header file on the project?? right now it is creating just one for the entire project... Thanks
-
hi there i have a project in visual c++ 7, with a main.cpp file, and 5 header files used by the main file. how do i get the compiler to generate a .obj file for each header file on the project?? right now it is creating just one for the entire project... Thanks
.obj files (called object files) are generated from .cpp files (source files), not .h files (header files). Header files are used to share declarations between two or more .cpp files. Here's an example header file,
ClassA.h
:class ClassA {
public:
ClassA();
~ClassA();
int A;
};and the corresponding source file,
ClassA.cpp
#include "ClassA.h"
ClassA::ClassA()
: A(0)
{
};ClassA::~ClassA()
{
};and the main program,
Main.cpp
#include "ClassA.h"
int main(int argc,char *argv[])
{
ClassA An_A;
//...
}From this example, there would be two object files,
ClassA.obj
andMain.obj
.ClassA.h
is#include
'd by both of them to ensure that they both agree on the declaration ofClassA
.
Software Zen:
delete this;