无法重新定义struct TM错误

时间:2017-06-28 20:55:45

标签: c++

我已经尝试过Codeblocks和Clion上的代码,我仍然在重新定义struct tm错误。

#include <iostream>
#include <ctime> // Needed for the true randomization
#include <cstdlib>
using namespace std;

int main ()
{
    int xRan;
    srand( time(0)); // This will ensure a really randomized number by help of time.

    xRan=rand()%15+1; // Randomizing the number between 1-15.
    cout << "Shows a random number between 1-15: " << xRan;

    return 0;
}

When ever I use the library I get the error. Not sure if theres something 
minigw包含文件夹中的错误或什么。会删除我的所有想法并重新安装帮助吗?任何想法可能都是为什么?

In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ctime:42:0,

来自C:\ Users \ Kelvindavis \ CLionProjects \ untitled \ main.cpp:2: c:\ mingw \ include \ time.h:172:8:错误:重新定义&#39; struct tm&#39; struct tm         ^     在包含的文件中     C:\ MinGW的\ lib中\ GCC \的mingw32 \ 5.3.0 \包括\ C ++ \ cwchar:44:0,                  从     C:\ MinGW的\ lib中\ GCC \的mingw32 \ 5.3.0 \包括\ C ++ \位\ postypes.h:40,     来自c:\ mingw \ lib \ gcc \ mingw32 \ 5.3.0 \ include \ c ++ \ iosfwd:40,     来自c:\ mingw \ lib \ gcc \ mingw32 \ 5.3.0 \ include \ c ++ \ ios:38,     来自c:\ mingw \ lib \ gcc \ mingw32 \ 5.3.0 \ include \ c ++ \ ostream:38from     C:\ MinGW的\ lib中\ GCC \的mingw32 \ 5.3.0 \包括\ C ++ \的iostream:39from     C:\ Users \用户Kelvindavis \ CLionProjects \名字\ main.cpp中:1:     c:\ mingw \ include \ wchar.h:87:8:错误:以前定义&#39; struct tm&#39;     struct tm {         ^     mingw32-make.exe [3]: * [CMakeFiles / untitled.dir / main.cpp.obj]错误1     CMakeFiles \ untitled.dir \ build.make:61:目标配方     &#39; CMakeFiles / untitled.dir / main.cpp.obj&#39;失败     CMakeFiles \ Makefile2:66:目标的配方&#39; CMakeFiles / untitled.dir / all&#39;     失败     CMakeFiles \ Makefile2:78:目标的配方&#39; CMakeFiles / untitled.dir / rule&#39;     失败     mingw32-make.exe [2]: [CMakeFiles / untitled.dir / all]错误2     mingw32-make.exe [1]: [CMakeFiles / untitled.dir / rule]错误2     mingw32-make.exe:* [无标题]错误2     Makefile:117:目标配方&#39;无标题&#39;失败

0 个答案:

没有答案