LNK2019 Error under Visual Studio 2010

后端 未结 4 1227
傲寒
傲寒 2021-01-22 19:35

I have created a sample c++ project under Visual Studio 2010 with following files.

A.h

#ifndef A_H
#define A_H

#include 

void foo();

#         


        
4条回答
  •  执笔经年
    2021-01-22 20:12

    EDIT: Nevermind the original answer (below), I believe what you're looking for may be here: Visual Studio 2010's strange "warning LNK4042"

    Original answer (not the problem, but maybe sound advice?): Your header should have guards around it, otherwise it will be defined each time it is called, and cause redefinitions.

    #ifndef A_H
    #define A_H
    
    #include 
    
    void foo();
    
    #endif //A_H
    

提交回复
热议问题