Search code examples
c++visual-studio-2010compiler-errorsstatic-membersbuild-error

Build failed vs compilation failed


I am confused regarding build failed and compilation failed. If I write some code in Visual Studio then if it reports Build Failed does that also mean that compiler has caught some errors in the program?

Actually after initialzing static variable multiple times, I am getting the build error.

<code>
int Child::count = 1;
int Child::count = 2;
</code>

<code>
1>c:\users\muzammil\desktop\testproject\testproject.cpp(93): error C2374: 'count' : redefinition; multiple initialization
1>          c:\users\muzammil\desktop\testproject\testproject.cpp(83) : see declaration of 'count'
1>
1>Build FAILED.
</code>

Solution

  • A "build" generally refers to the complete process of turning your code and other associated resources into a distributable package whereas "compiling" is just converting the source code to an executable format. In this case, your compilation failed. Since that is one step of the build process, then you can also say the build failed.

    Are you also asking how to fix that error? The answer is simply don't declare the same variable multiple times in the same context.