MyClass
\MyClass.cc (constructor)
\functionForMyClass. cc
\anotherFunctionForMyClass.cc
OtherClass
\OtherClass.cc (constructor)
Whether this is a good practice is something I don’t want to discuss, because I’m just using this Organize my project in this way.
I am using visual studio 2008, and when using the same-named function (and file name) in two classes, weird link errors occur. This seems to be due to Visual studio puts all the .obj files (one for each source file) in an intermediate directory, and overwrites the previously generated object file when compiling the source file with the same name.
This can be done according to the input file The relative path of the target file is placed in a subdirectory to solve. Visual Studio allows users to configure the name of the target file it generates, and use macros there, but it seems that there is no “input file relative path” macro.
So, is there a way to make this work? If not, what is the best solution to use one project for each class?
Project Properties-C/C++-Output Files-Object File Name http: //img37.imageshack.us/img37/3695/outputfile.png
PS. It sounds like the instructor has a crappy (maybe written by the instructor himself) automatic code validator, which imposes this restriction To get extra markup, please provide a rewrite parser so that it can be used with normal/reasonable/non-weird project layouts.
I am learning for what I am The c course developed a static library project. The teacher insisted that we only define one function for each source file, and group files/functions belonging to the same class into subdirectories of each class. This leads to the following structure:
MyClass
\MyClass.cc (constructor)
\functionForMyClass.cc
\anotherFunctionForMyClass.cc
OtherClass
\OtherClass.cc (constructor)
Whether this is good practice is something I don’t want to discuss, because I just organize my project in this way.
I am using visual studio 2008, and when using the same-named function (and file name) in two classes, there will be a strange link error. This seems to be due to visual studio putting all .obj files (one for each source file) in one In the intermediate directory, when compiling the source file with the same name, the previously generated target file is overwritten.
This can be solved by placing the target file in a subdirectory according to the relative path of the input file. Visual Studio allows The user configures the name of the target file it generates and uses macros there, but there seems to be no “input file relative path” macro.
So, is there a way to make this work? If not, what is the best solution to use one project for each class?
You are right, by default, all target files are placed in the same directory, and the file name is based on the source file name. The only thing I can think of The solution is to change the output file path of the conflict file here:
Project Properties-C/C++-Output Files-Object File Name http://img37.imageshack.us/img37/3695/ outputfile.png
PS. It sounds like the instructor has a crappy (perhaps written by the instructor himself) automatic code validator that imposes this restriction. For additional markup, please provide a rewrite parsing So that it can be used with normal/reasonable/non-weird project layouts.