GCC编译器错误:“重新定义...先前定义” [英] GCC compiler error: "redefinition...previously defined"
本文介绍了GCC编译器错误:“重新定义...先前定义”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到了很多在此重新定义x .... x的信息。请这个错误是什么意思?
I'm getting a lot of " redefinition of x....x previously defined here". Please what does this error means?
推荐答案
您需要限制每个文件只包含一次。您可以通过2种方式执行此操作。
You need to limit each file from being included only once. You can do this in 2 ways.
1)在头文件的顶部放置:
1) At the top of your header files put:
#pragma once
或2)如果您的编译器不支持,请放在顶部/结尾头文件的大小:
Or 2) if your compiler doesn't support that, put at the top/end of your header files:
#ifndef _MYFILE_H_
#define _MYFILE_H_
...
#endif
将MYFILE替换为文件名,并用...的内容替换...头文件。
Replace MYFILE with the name of your file, and replace ... with the contents of the header file.
这篇关于GCC编译器错误:“重新定义...先前定义”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文