The situation and solution of Link1169 in C++

Link1169 appears, usually one or more functions are found in the compiled obj file, so that the link does not know which function to choose

  1. Code Situation:
    File A:
    #include <iostream>
    
    #define cs int
    
    cs Mutiply(int a,int b) {
    	cs result = a * b;
    	return result;
    #include "flag.h"
    
    
    void Log(const char* message) {
    		std::cout << message << std::endl;
    }
    file B:
    #include <iostream>
    
    void Log(const char* message) {
        std::cout << message << std::endl;
    }
    file C:
    #include <iostream>
     
    
    void Log(const char* message); 
    
    
    int main() {
        Log("Hello world!");
        std::cin.get();
    }
    
    
    In the case of the above code, file B and file A have exactly the same Log() function, so when looking for links, I don’t know which one to choose.

     
  2. Solution: Delete the Log() function in file B or file A

Guess you like

Origin blog.csdn.net/dantui_/article/details/130114730