VC finds one or more multi-defined symbols

Source: Internet
Author: User

VC find one or more multi-definition of the symbol, this problem is still not a good solution.

The fundamental thing is that all the relevant definitions are placed in the. cpp file, and only the declarations are placed in the corresponding. h file.
This allows you to completely avoid the phenomenon of symbolic redefinition when you include "".

In case this happens, try the following two ways to solve it:

1.vs2005, adding/force to the additional options in the command line, linker--------Properties

2. Adding a static label to a multi-defined symbol can be a good solution

Declare a global variable, the global function must be declared in the CPP, the other class refers to the global variable to include the CPP h file, and then an extern, otherwise it is easy to see the duplicate definition error.
How does this "easy" explain it?
For example A.h if the global variable int global is declared; In B.h, include "A.h" extern int Global;
Then you include A.h equivalent to the declaration of global variables in A.h also included, the compiler will be considered a duplicate definition. So global variables and function declarations must be in CPP!
1. When a function is implemented in the. h file, the VS2005 compiler reports this error, and the workaround: 1) Add inline before the function declaration in. h
2) Add/force in the additional options, command line, linker, properties----

2. When the function implementation is in a. cpp file, add the inline before the function implementation

VC finds one or more multi-defined symbols

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.