Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: tiutea on September 13, 2016, 10:37:12 am

Title: Error
Post by: tiutea on September 13, 2016, 10:37:12 am
I tried example from Prata book and got error
CODE:

Code
#include<iostream>
#include <ctime>
#include <cstdlib>
#include "String.h"
const int MIN_PER_HR=60;
bool newcustomer(double x);
int main(){
    using namespace std;
    srand(time(0));

    return 0;
}


P.S. downloaded and installed codeblocks 16.01 on Win7




ERROR


||=== Build: Debug in book (compiler: GNU GCC Compiler) ===|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|60|error: '::clock_t' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|64|error: '::clock' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|65|error: '::difftime' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|66|error: '::mktime' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|67|error: '::time' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|68|error: '::asctime' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|69|error: '::ctime' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|70|error: '::gmtime' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|71|error: '::localtime' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|72|error: '::strftime' has not been declared|
D:\z\book\main.cpp||In function 'int main()':|
D:\z\book\main.cpp|9|error: 'time' was not declared in this scope|
||=== Build failed: 11 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Title: Re: Error
Post by: ollydbg on September 13, 2016, 05:08:30 pm
Read the FAQ: My simple C++ program throws up lots of errors - what is going on? (http://wiki.codeblocks.org/index.php/FAQ-Compiling_(errors)#Q:_My_simple_C.2B.2B_program_throws_up_lots_of_errors_-_what_is_going_on.3F)
Title: Re: Error
Post by: stahta01 on September 13, 2016, 05:29:46 pm
I suggest posting a build log in code tags instead of build messages.

I also suggest removing the include of "String.h".

http://wiki.codeblocks.org/index.php/FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (http://wiki.codeblocks.org/index.php/FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)